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 7490219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:34:01+00:00 2026-05-29T15:34:01+00:00

i am using vestal_version in my rails app. And i am wondering how do

  • 0

i am using vestal_version in my rails app. And i am wondering how do I show the previous versions edit links with respect to what is at the above entry. My html.erb code is

        <tbody>
                        <% @page.versions.each do |page| %>
                        <tr class="odd">
                          <td><input type="checkbox" /></td>
                          <td> </td>
                          <td><%= page.created_at%></td>
                          <td>
                          <% if params[:version] %>
                          <%= link_to "Previous Version", :version => @page.version-1 %>
                          <%end%>
                        </td>
                        </tr>


                  </div>
         <% end %>

and in controller i have @page.revert_to(params[:version].to_i) if params[:version]

I have attached a link to the screenshot. And if closely observe. the ?version=5 for all the entries. I want to have all the versions that is 1,2,3,4 and 5. How do i do that ?

Update : Image is hyper linked in the comment. I am not allowed add an image as of now.

  • 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-05-29T15:34:01+00:00Added an answer on May 29, 2026 at 3:34 pm

    Use page instead of @page.

    <%= link_to "Previous Version", :version => page %>
    

    page changes with each iteration, while @page stays the same.

    EDIT:

    Since @page.versions.each iterates a collection of versions, it should be passed into the block as version, not page.

    <% @page.versions.each do |version| %>
      <tr class="odd">
        <td><input type="checkbox" /></td>
        <td> </td>
        <td><%= version.created_at%></td>
        <td>
        <%= link_to "Show Version", :version => version %>
        </td>
      </tr>
    <% end %>
    

    This method only shows the version. Actually reverting a version should be done via POST, since you are making changes to the database.

    Reverting negates changes, it does not discard changes. If page is at version 4, and you revert to version 2, it does not delete versions 3 and 4. The version number will revert to 2, but will count as a version itself.

    #revert_to does the reversion but does not save. To revert and save, use #revert_to!


    To properly use #revert_to!, you need to put it in a controller action.

    Example, in your pages controller:

    def revert
      @page = Page.find params[:id]
      if @page.revert_to!(params[:version_id]) # <= revert_to!
        redirect_to @page
      else
        render :text => "Did not revert"
      end
    end
    

    In your routes.rb:

    resources :pages do
      member do
        post 'revert_to/:version_id' => 'pages#revert', :as => :revert
      end
    end
    

    then in your view:

    <% @page.versions.each do |version| %>
      <tr class="odd">
        <td><input type="checkbox" /></td>
        <td> </td>
        <td><%= version.created_at %></td>
        <td>
        <%= link_to "Show Version", :version => version %>
        </td>
        <td>
        <%= button_to "Revert to this version", revert_page_path(@page, version.id) %>
        </td>
      </tr>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Rails 3 Vestal Versions gem: https://github.com/lailsonbm/vestal_versions I'd like to create some
I'm real interested in using Vestal Versions with Rails 3. Does anyone know if
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
Using Rails 3.2.0 with haml and sass: I Would like to link an external
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Using Rails 3.2.0 with haml, sass and coffeescript: Basically I am trying to disable
Using Python, I'm trying to connect to my AppEngine app's remote_api handler, but I
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
Using HTML 5, I want to play multiple sounds simultaneously. how can I do
Using Rails 3, but I guess doesn't matter. I put this in the template

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.