On Tuesday, June 12, 2012 3:55:32 PM UTC-4, akkdio wrote:
>
>
>
>
>> > Perhaps it is something basic as a beginner I am.  I have the 
>> following: 
>>
>> There was no need to show all this code, it is easier for us to see 
>> what is going on if you just show the relevant bits 
>>
>> Understand and thanks.  
>
>> > [snip] 
>>
>> > 
>> > I want the following partial to be shown in the Main#Welcome view: 
>> > 
>> > partial is located in the composer view folder: 
>> > 
>> > <h3>Editions List</h3> 
>> > <ul> 
>> > <% @composer.editions.map do |edition| %> #line 3 in error below 
>> > [snip] 
>> > 
>> > My limited knowledge believes the call to the partial should work and 
>> indeed 
>> > it does if done like this within the Composer#Show view: 
>> > 
>> > <%= render "edition" %> 
>> > 
>> > However, when I make the partial call from the Main#Welcome view like 
>> this: 
>> > The Main#Welcome view: 
>> > <%= render :partial => "composers/edition" %> 
>> > 
>> > It results in this error: 
>> > 
>> > NoMethodError in Main#welcome 
>> > 
>> > Showing 
>> > 
>> /Users/akkdio/railsapps/rails_3/ruby_for_rails/r4r_music/r4r_music1/app/views/composers/_edition.html.erb
>>  
>>
>> > where line #3 raised: 
>> > 
>> > undefined method `editions' for nil:NilClass 
>>
>> That means that @composer is nil, since that is the object on which 
>> 'editions' is being called. 
>>
>> Have a look at the Rails Guide on Layouts and Rendering, particularly 
>> the section Using Partials to see how to pass local variables to the 
>> partial. 
>>
>> Also have a look at the guide on debugging to get ideas on how to 
>> debug your code so that you can work out what is going on. 
>>
>
> Will check this. thanks.  
>
>>
>> I notice that you have asked for help twice before on this list and 
>> neither time did you reply to the suggestions offered or report 
>> whether you had found a solution. :( 
>>
>
> Not an excuse but I was not notified of the someone answering... Sorry.   
> This time I checked back and check "email updates to me" Sorry again - I 
> appreciate all the guidance i can get.    
>
>>
>> Colin 
>>
>
My solution/learning (sort of) I read through the Rails Guide and it was 
somewhat helpful - lots to learn -  

My disconnect however that I was under the impression that the partial 
because it worked when I used in the composer show method it would work in 
the Main#Welcome view.  Well, this is incorrect because in the 
Composer#Index view I click on the Composer ID (set up as a link_to on the 
id:

 <td><%= link_to composer.id, composer_path(composer) %></td>

This is how the partial gets the composer id in order  make the editions 
partial work and why the editions method returned a Nil when called from 
the Main#welcome view.  It was saying " what composer?  I can't find no 
stinking Composer"   If I do want the editions listed in the Main#Welcome 
view for each composer then I will have to find a way to send the editions 
method the composer id it is looking for.   Time for more reading.

Thanks all for the nudge.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/rjdaeRelwt4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to