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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:13:49+00:00 2026-05-23T03:13:49+00:00

I have an attribute to add a page to my site’s navigation (its a

  • 0

I have an attribute to add a page to my site’s navigation (its a boolean) and I want to be able to turn pages on and off from check boxes all at once. I tried following this railscast:
http://railscasts.com/episodes/52-update-through-checkboxes but Im running into two problems.

One – I want the check boxes to show the current state of the “navbar” option.

and two – Im not sure how to update the navbar field.

Here is my controller:

  def nav
    Section.update_all([:navbar => :params[:navbar]], :id =>params[:section_ids])
    flash[:success] = "Sections were added to navbar"
    redirect_to(admin_sections_path)
  end

and my view:

<%= form_tag nav_admin_sections_path, :method => :put do %>
  <ol id="section_list" class="records_list">
  <% @sections.each do |section| %>
    <li id="section_<%= section.id %>">
    <table>
      <tr class="handle">
        <td class="title link_icon directory_link"><%= section.name %></td>
        <td class="option"><%= check_box_tag "section_ids[]", section.id %></td>
        <td class="action"><%= link_to 'Edit', edit_admin_section_path(section), :class=>"link_icon edit_link"   %></td>
        <td class="action">
          <% if section.has_bio == false %>
          <%= link_to 'Destroy', admin_section_path(section), :confirm => 'Are you sure?', :method => :delete, :class=>"link_icon delete_link"   %>
          <% end %>
        </td>
      </tr>
      </table>

    </li>
  <% end %>
  </ol>

  <ol>
    <li class="submit">
      <%= submit_tag %>
    </li>
  </ol>
<% end %>

The table is nested in the list item because of some jquery-ui sortable stuff Im doing.

Anyway I need that check box to show the current state of :navbar AND I need to be able to update them. Right now if I try to update them I get this error:

    can't convert Symbol into Integer
app/controllers/admin/sections_controller.rb:95:in `[]'
app/controllers/admin/sections_controller.rb:95:in `nav'

on this line in my controller”

Section.update_all([:navbar => :params[:navbar]], :id =>params[:section_ids])

So I guess Im not passing the check_box state into my controller correctly.

  • 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-23T03:13:50+00:00Added an answer on May 23, 2026 at 3:13 am
    1. Have the checkbox check properly. Just add the boolean as the third argument.

      <td class="option"><%= check_box_tag "section_ids[]", section.id, section.navbar %></td>
      
    2. update the navbar field You’ll have to set both the sections where navbar is on and off.

      ids = [*params[:section_ids]] + [0] # makes sure it works when no navbars are selected
      Section.update_all({:navbar => true}, {:id => ids})
      Section.update_all({:navbar => false}, "sections.id NOT IN (#{ ids.join(',') })")
      

    EDIT

    Needs double quotes instead of single quotes in second update_all. Updated the above code.

    EDIT 2

    Enclosing the comma inside the join in quotes

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

Sidebar

Related Questions

Question 1) I have a control to which I add an attribute from the
I want to add or remove jquerymobile attribute data-role=button from anchor tag on window
I have an attribute in my user database of type Date. I want to
my issue is that I have an attribute as 'attribute' coming in from entity
I have three different like buttons on three different pages in my site. Is
I have a site I'm working on where I want to mark if a
When you add social media buttons to your site from Google+, Facebook, LinkedIn etc.,
I have created a blank asp.net website consisting of a blank default.aspx page, its
So I have a site with a dozen pages on it using Drupal as
I have an anchor in my HTML. it has a page attribute with a

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.