1 2 3 4 5 6 7 8 9 10 11 | <% @articles.each do |article| %> <tr> <td><%= article.title %></td> <td><%= article.keywords %></td> <td><%= article.content %></td> <td><%= link_to 'Show', article %></td> <td><%= link_to 'Edit', edit_article_path(article) %></td> <td><%= link_to 'Destroy', article, :confirm => 'Are you sure?', :method => :delete %></td> </tr> <% end %> |
1 2 3 4 5 6 7 | def index @articles = Article.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @articles } end end |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | def create @article = Article.new(params[:article]) respond_to do |format| if @article.save format.html { redirect_to(@article, :notice => 'Article was successfully created.') } format.xml { render :xml => @article, :status => :created, :location => @article } else format.html { render :action => "new" } format.xml { render :xml => @article.errors, :status => :unprocessable_entity } end end end |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |