Ruby on Rails Monday, December 1, 2014

sure.

posts_controller.rb

...
private
  def post_params
      params.require(:post).permit(:title, :body)
  end

class CreatePosts < ActiveRecord::Migration
  def change
    create_table :posts do |t|
      t.string :title
      t.text :body
      t.integer :user_id
      t.timestamps
    end
  end
end 


comments_controller.rb
...
private
  def comment_params
      params.require(:comment).permit(:body)
  end


class CreateComments < ActiveRecord::Migration
  def change
    create_table :comments do |t|
      t.integer :body
      t.integer :post_id
      t.integer :user_id
      t.timestamps
    end
  end
end


thank you






--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/efba776f-02fc-4030-a3d8-7ecf942afe99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment