0

I am trying to learn the new changes in rails 4 so started with a blog . Ran a scaffold with a title and body , everything went well until i clicked on save and i was greeted with the error ActiveModel::ForbiddenAttributesError . I know i need to make some changes in controller , but i read the blogs and made changes for the same .

Following is my controller

class BlogpostsController < InheritedResources::Base
  def create
     Blogpost.create(blogpost_params)
  end

  private
  def blogpost_params
    params.require(:blogpost).permit(:body,:title)
  end
end

Please do point me the right way as i am still new to rails 4 and also any tutorials defining the same would also be helpful . Thanks in advance :)

Andrii Furmanets
  • 1,081
  • 2
  • 12
  • 29
Caffeine Coder
  • 1,869
  • 1
  • 17
  • 35

1 Answers1

0

You have controller code in a model class , that's what wrong. The create action and the strong parameters should be defined in your blog_posts controller. The code itself seems fine.

rails4guides.com
  • 1,441
  • 2
  • 11
  • 8