Colin Law wrote:
> On 20 May 2010 16:35, Ravi Dtv <[email protected]> wrote:
>>>>
>>
>> �format.xml
>> "2010-05-17 14:00:13", user_id: 9, group_name: "testinggroup">
>> �from (irb):43
> That is because @friendsingroup is an array because you have used
> find_all_by_... The clue is in the error message. It says that class
> Array has not got a method group_id
>
>>
>> In view I get the following error
>>
>> �RuntimeError in UsersController#showfriendslist
>>
>> Called id for nil, which would mistakenly be 4 -- if you really wanted
>> the id of nil, use object_id
>
> That means that you have used something.id where id is nil. You still
> have not told us which line in the view is giving the error. Look at
> the error message and see which line it is, then look to see what id
> you are using on that line and most likely you will find the nil
> object. Then you just have to work out why it is nil. In order to
> avoid your view crashing you could test it for nil and put a message
> in the view instead of allowing it to crash.
>
> I also suggest also that you have a look at the Rails Guide on
> debugging. It will show you ways of breaking in to your code to
> inspect the variables. I use ruby-debug when I have this sort of
> problem.
>
> Colin
Thanks Colin for the reply.
When debugging i find currentgroupid is nill.
How can I solve this. Possible solutions to pass values form partial to
controller.
<% @groups.each do |g| %>
<p>
<h5>
<%= link_to_remote g.group_name, :update => "abc", :url => {
:controller =>
"users" , :action => "showfriendslist" } %>
<%= hidden_field_tag :group_name %>
</h5>
</p>
<% end %>
I can see my groupname displaying in my page, but when I click on my
groupname link, Im not able to pass groupname to my controller.
My controller:
def showfriendslist
@currentgroupid=Group.find_by_group_name(params[:group_name]).id
#...@friendsingroup=groupfriend.find_all_by_user_id_and_group_id(current_user.id,@currentgroupid)
respond_to do |format|
format.html {render :partial => "friendlist" }
format.xml
end
end
Please help. Thank you.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
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.