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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:25:02+00:00 2026-05-24T11:25:02+00:00

I have been using rails for about a month, mostly loving it, sometimes infuriating

  • 0

I have been using rails for about a month, mostly loving it, sometimes infuriating (I haven’t yet gotten particularly efficient at debugging through the magic).

I have a gallery page that extends from a something called simply page. Each gallery page has many gallery images.

class Gallery < Page
  belongs_to :page, :dependent => :destroy
  has_many :gallery_images, :dependent => :destroy
  accepts_nested_attributes_for :gallery_images
end

class GalleryImage < ActiveRecord::Base
  has_attached_file :image, :styles => { :medium => "600x600>", :thumb => "100x100>" }
  belongs_to :gallery
end

I am trying to edit the gallery through the pages controller.

  def edit
    @page = Gallery.find(params[:id])
    @house = @page.house
  end

Through the page/edit.html.erb i render the gallery form partial

<%= form_for @page do |f| %>
  <p><b>Images</b></p>
    <% for image in @page.gallery_images %>
        <%= image.image.url(:thumb) %>
    <% end %>

  <%= f.fields_for :gallery_images do |builder| %>
    <% render :partial => "galleries/gallery_image_fields", :f => builder %>
  <% end %>

  <p><%= f.submit %></p>
<% end %>

In galleries/gallery_image_fields i have

<p class="fields">
  <%= f.label :image %><br />
  <%= f.file_field :image %>
</p>

Now the urls for the above image print out so it seems that the relashionship is working fine, however I get the enormously frustrating error message.

undefined local variable or method `f’ for #<#:0x210eb34>
Showing mypathblahblah/app/views/galleries/_gallery_image_fields.html.erb where line #2 raised:

If anyone has a solution that would obviously be perfect otherwise some thoughts into how one might debug this problem would be great too. I tried outputting debug builder but it didnt really help me.

Thanks

  • 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-24T11:25:03+00:00Added an answer on May 24, 2026 at 11:25 am

    Try changing:

    <% render :partial => "galleries/gallery_image_fields", :f => builder %>
    

    into:

    <% render :partial => "galleries/gallery_image_fields", :locals => { :f => builder } %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using ruby exclusively for about a month and I really love
I have been using the Rails console a fair bit lately and its making
I have been using ActiveResource in my Ruby on Rails applications for some time,
I've been trying to build my first rails app and have gotten stuck on
I have been using Rails for over 4 years so obviously I like Rails
I have been using the Zend Framework with an MVC configuration, read about Ruby
I have been following the Railscast #270 found Rails Cast #270 about implementing Authentication
I've been reading about routing in Rails 3 and have been unsuccessful in achieving
We have been using CruiseControl for quite a while with NUnit and NAnt. For
I have been using PHP and JavaScript for building my dad's website. He wants

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.