Rails : can't write unknown attribute `url'
- by user2954789
I am new to ruby on rails,and I am learning by creating a blog. I am not able to save to my blogs table and I get this error "can't write unknown attribute url"
Blogs migration :db/migrate/
class CreateBlogs < ActiveRecord::Migration
--def change
--- create_table :blogs do |t|
---- t.string :title
---- t.text :description
---- t.string :slug
---- t.timestamps
--- end
--end
end
Blogs Model :/app/models/blogs.rb
class Blogs < ActiveRecord::Base
--acts_as_url :title
--def to_param
---url
--end
--validates :title, presence:true
end
Blogs Controller : /app/controllers/blogs_controller.rb
class BlogsController < ApplicationController
before_action :require_login
--def new
--- @blogs = Blogs.new
--end
--def show
---@blogs = Blogs.find(params[:id])
--end
--def create
---@blogs = Blogs.new(blogs_params)
--if @blogs.save
---flash[:success] = "Your Blog has been created."
---redirect_to home_path
--else
---render 'new'
--end
-end
--def blogs_params
---params.require(:blogs).permit(:title,:description)
--end
private
--def require_login
---unless signed_in?
----flash[:error] = "You must be logged in to create a new Blog"
----redirect_to signin_path
---end
--end
end
Blogs Form:/app/views/blogs/new.html.erb
Blockquote
<%= form_for @blogs, url: blogs_path do |f| %><br/>
<%= render 'shared/error_messages_blogs' %><br/>
<%= f.label :title %><br/>
<%= f.text_field :title %><br/>
<%= f.label :description %><br/>
<%= f.text_area :description %><br/>
<%= f.submit "Submit Blog", class: "btn btn-large btn-primary" %><br/>
<% end %><br/>
and I have also added "resources :blogs" to my routes.rb file.
I get this error in controller at
if @blogs.save