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

  • Home
  • SEARCH
  • 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 9166999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:17:05+00:00 2026-06-17T15:17:05+00:00

I am trying to create a paginated index view in Rails 3.2 with a

  • 0

I am trying to create a paginated index view in Rails 3.2 with a drop down menu to select the number of items displayed per page. I am using the will_paginate gem and the pagination function is working great.

However, with my current setup shown below, I am getting validation errors when changing the drop down menu selection. It appears to be trying to create or save a Contact model instead of just making another request to the index action. Any help will be greatly appreciated.

Here is my index action:

def index
  #logic here to set per_page value depending on request?
  @contacts = Contact.paginate(page: params[:page], :per_page => 20)
end

Here is my index.html.erb view with my attempt at a drop down menu for items per page:

<%= form_tag({ :action => "index", :method => "get" }, { :id => "contacts-index" }) do %>
  <%= select_tag(:view, options_for_select([["10", 10], ["25", 25], ["50", 50]]), { :id => "switch-view" }) %>
<% end %>

<% @contacts.each do |contact| %>
  <%= contact.first_name %><%= contact.last_name %>
<% end %>

Lastly, here is the jQuery I am using to try to submit the new request to contacts#index when the items per page is changed:

$(document).ready(function() {
  $("#switch-view").change(function() {
    $("#contacts-index").submit();
  });
});
  • 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-17T15:17:07+00:00Added an answer on June 17, 2026 at 3:17 pm

    :method => get should be moved out of the first hash.

    <%= form_tag({ :action => "index"}, { :method => "get", :id => "contacts-index" }) do %>
    

    Without this, it’s doing a post and submitting the ‘method’ as a param. A post to the ‘index’ url will result in the validation errors you’re seeing.

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

Sidebar

Related Questions

I'm trying to create an index page where all assets are displayed including a
I'm trying to create a paginated UIScrollView within a view that only scrolls horizontally
So I'm trying to page items on my index page using the paginator and
I am trying to create a link, which will, allow my paginated search to
Trying to create a black line in my view to separate text blocks but
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I'm trying to create a page curl animation of an image in my iPhone
I'm trying to create a custom view, which has a rectangle, and some text
I'm trying to create a single, one-off page that will combine information from several
I am trying to create a news page for a website I am working

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.