Need some help regarding mercury editor in rails.
I followed following tutorial to use mercury editor in my app
goo.gl/q960Ka
In above tutorial they wrote following lines in migration file before
doing rake db:migrate
Page.create(
title: 'Lorem ipsum',
content: 'Lorem ipsum....
)
which every-time update first entry with id="1" of table instead of
creating new columns and then update it.
I use to set default value in migration table like
def change
create_table :pages do |t|
t.string :name
t.string :title => "test"
t.string :content => "test"
t.timestamps null: false
end
end
end
When I use to edit default values mercury didn't save the values,
instead I got this error message
NoMethodError (undefined method `[]' for nil:NilClass):
app/controllers/pages_controller.rb:9:in `save_page'
This is my controller file pages_controller,rb for save_page
def save_page
page = Page.find(params[:id])
page.title = params[:content][:page_title][:value]
page.content = params[:content][:page_content][:value]
page.save!
render text: ''
end
Please tell me how can I edit my default values and save that edited
values in new entry instead of updating single entry everytime
--
Cheers!
Deepak Kumar Sharma
Blog: http://deekysharma.wordpress.com
" Mistakes are proof that you are trying "
--
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/CALDHwN7r8Ht7sftSdHC%3DTHDgJGkbuo4xBeONxbi4MSwx_LHvgw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment