Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9143365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:00:21+00:00 2026-06-17T10:00:21+00:00

I am adding mercury to a simple blogging application and would like to use

  • 0

I am adding mercury to a simple blogging application and would like to use the newest version, but I have not been able to get it to save updates. Here is my code:

Gemfile:

gem 'rails', '3.2.11'
gem "thin", "~> 1.3.1"
gem 'mercury-rails'
gem 'paperclip'

group :development do
  gem 'taps'
  gem "nifty-generators"
  gem 'sqlite3'
end

gem 'jquery-rails'

blogs_controller.rb:

  def update
    @blog = Blog.find(params[:id])
    if @blog.update_attributes(params[:blog])
      redirect_to @blog
    else
      render 'edit'
    end
  end

  def mercury_update
    blog = Blog.find(params[:id])
    blog.content         = params[:content][:blogContent][:value]
    blog.save!
    render text: ""
  end

blog.rb:

class Blog < ActiveRecord::Base
  attr_accessible :title, :content, :author
end

routes.rb:

  Mercury::Engine.routes
  mount Mercury::Engine => '/'
  root :to => "pages#home"

  namespace :mercury do
    resources :images
  end

  resources :blogs do
    member { post :mercury_update }
  end

mercury.html.erb

  <body>
    <script type="text/javascript">
      // Set to the url that you want to save any given page to, leave null for default handling.
      var saveUrl = null;

      // Instantiate the PageEditor
      new Mercury.PageEditor(saveUrl, {
        saveStyle:  'form', // 'form', or 'json' (default json)
        saveMethod: null, // 'PUT', or 'POST', (create, vs. update -- default PUT)
        visible:    true  // boolean - if the interface should start visible or not
      });
    </script>
  </body>

blogs/show.html.erb:

 <div id="blogFull" class="rounded-corners-mild">

 <div id="blogTitle">
   <h1 style="font-size:150%; text-align:center; " class="mercury-region" ><%= @blog.title%></h1>
  </div>

  <div data-mercury="full" id="blogContent" class="mercury-region">
    <%= raw @blog.content %>
  </div><br />
  <%= link_to "mercury", "/editor" + "/blogs" + "/#{@blog.id}", :class => 'bestButton',  
          id: "edit_link", data: {save_url: mercury_update_blog_path(@blog)} %>

added to: mercury.js:

jQuery(window).on('mercury:ready', function() {
        var saveUrl = $("#edit_link").data("save-url");
        Mercury.saveUrl = saveUrl;
});
Mercury.on('saved', function() {
        window.location.href = window.location.href.replace(/\/editor\//i, '/');
});

I also tried with this: to mercury.js:

  onload: function() {
    //Mercury.PageEditor.prototype.iframeSrc = function(url) { return '/testing'; }
    Mercury.on('ready', function() {
      var link = $('#mercury_iframe').contents().find('#edit_link');
      Mercury.saveUrl = link.data('save-url');
      link.hide();
    });

    Mercury.on('saved', function() {
      window.location.href = window.location.href.replace(/\/editor\//i, '/');
    });
  }

Neither worked. Both got me to the editor and allowed me to edit. I have not been able to save any changes yet. Thank You.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:00:23+00:00Added an answer on June 17, 2026 at 10:00 am

    Do you get an error message when trying to save? What does it say? If it says it’s unable to save but the URL is correct you want to check your log file.

    I had problems setting the correct saveUrl and adding the following to mercury.js fixed it for me;

    onload: function() {
        Mercury.on('ready', function() {
            var link = $('#mercury_iframe').contents().find('#edit_link');
            console.log("mercury ready ready", link);
            mercuryInstance.saveUrl = link.data('save-url');
            link.hide();
        });
    
        Mercury.on('saved', function() {
            window.location.href = window.location.href.replace(/\/editor\//i, '/');
        });
    }
    

    Found it in this thread on RailsCasts.

    Edit:

    I notice something else in your code. You created a route for a POST action. In mercury.html.erb the saveMethod gets set to ‘PUT’ by default. Change the saveMethod to ‘POST’.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Adding Exceptional Handling is a good practise, but I have a doubt, In our
Adding strings localization files in iPhone bundle is very simple and perfectly fine but
Adding contents to listview is a simple proceess like ListViewItem item = new ListViewItem();
adding the words AND, OR, NOT to a search query raises an error like
Adding attributes to members works well because the syntax is exactly like it would
Adding files to .hgignore will prevent them from being tracked. But we have some
Adding the row one by one in the button click.. (i tried but its
After adding a second persistence unit and changing my application's data sources to XADataSource
Adding some gui modifications and I want to have a button which is 10pixels
Adding support for Unicode passwords it an important feature that should not be ignored

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.