Mercury editor not saving default values

Need some help regarding mercury editor in rails.

I followed following tutorial to use mercury editor in my app

In above tutorial they wrote following lines in migration file before
doing rake db:migrate

    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

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]!

    render text: ''

Please tell me how can I edit my default values and save that edited
values in new entry instead of updating single entry everytime

You have not told us which is line 9 but presumably it is one of the
above. Have a look in the log file to see what params is for the
request and check that it has the contents referenced above
(page_title and page_content and each of those has :value).


Yes, it worked I looked into log file and I found I forgot to add "id"
element in some tags + passing wrong "id" elements in others. Somehow
I'm able to make to it run but I encountered with another error. Error
is like this

I followed Railscast mercury tutorial to set up future stuff like link
for edit, saving edited content etc.

I'm able to edit but not able to save. I google alot but not able to
find solution. Can please tell me where I'm doing wrong


$(window).bind('mercury:ready', function() {
    var link = $('#mercury_iframe').contents().find('#edit_link');
    Mercury.saveUrl ='save-url');

$(window).on('mercury:saved', function() {
   window.location.href = window.location.href.replace(/\/editor\//i,


ActionController::RoutingError (No route matches [PUT]
  web-console (2.1.0) lib/web_console/middleware.rb:37:in `call'

So is the problem that it should not be using that url, that it should
not be a PUT, or that the route is missing?


It should not using this url.

What have you got in routes.rb to provide the route?



resources :pages do
  member { post :mercury_update }


def mercury_update
    page = Page.find(params[:id])
    page.subject = params[:content][:page_subject][:value]
    page.regard = params[:content][:page_regard][:value]
    page.regardContent = params[:content][:page_regardContent][:value]!
    render text: ''

What have you got in routes.rb to provide the route?


That is routes.rb I hope

resources :pages do
  member { post :mercury_update }

How does that provide the quotations route?

If you run rake routes you will see all the routes that defines.

Did you work right through a good tutorial such as
as I suggested you did a little time ago?

Also look at the rails guide on routing (and all the other guides actually).


Error Solved :slight_smile:

I used to solve error by changing method name in pages_controller.rb file.

s / def mercury_update / def update

def update
    page = Page.find(params[:id])
    page.subject = params[:content][:page_subject][:value]!
    render text: ''

Thanks for help.