I''m newbie. Please, help. I suppose it''s easy :) I have admin controller which is working ok and with usual controller I have trouble. This is app/controllers/team_controller.rb ____________________________________________ class TeamController < ApplicationController def show @team = Team.find(params[:id]) end end ___________________________________________ And in app/controllers/admin/teams_controller.rb "Show" function is absolutely same. Then, app/views/admin/teams/show.rhtml looks like <% for column in Team.content_columns %> <p> <% if column.human_name != "Image" %> <b><%= column.human_name %>:</b> <%=h @team.send(column.name) %> <% else %> <%= image_tag url_for_file_column :"team", :"image" %> <% end %> </p> <% end %> But when I try to use this code in app/views/team/show.rhtml I get an error: " Showing app/views/team/show.rhtml where line #6 raised: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.split" --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jan 13, 2008, at 3:51 PM, sublime wrote:> I''m newbie. Please, help. I suppose it''s easy :) > I have admin controller which is working ok and with usual controller > I have trouble. > This is app/controllers/team_controller.rb > ____________________________________________ > class TeamController < ApplicationController > def show > @team = Team.find(params[:id]) > end > end > ___________________________________________ > > And in app/controllers/admin/teams_controller.rb "Show" function is > absolutely same.Are you defining Admin::TeamsController in that file?> Then, app/views/admin/teams/show.rhtml looks like > <% for column in Team.content_columns %> > <p> > <% if column.human_name != "Image" %> > <b><%= column.human_name %>:</b> <%=h @team.send(column.name) %> > <% else %> > <%= image_tag url_for_file_column :"team", :"image" %> > <% end %> > </p> > <% end %> > But when I try to use this code in app/views/team/show.rhtml I get an > error: > " Showing app/views/team/show.rhtml where line #6 raised: > You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.split"I assume that @team.image is perhaps nil? Try this and see if you begin to understand what your code is doing: <% if column.human_name != "Image" %> <b><%= column.human_name %>:</b> <%=h @team.send(column.name) %> <% elsif @team.image.nil? %> <span>Oops! The image is nil</span> <% else %> <%= image_tag url_for_file_column :"team", :"image" %> <% end %> You really should understand what''s happening with the scaffold code (and replace it with your actual code, scaffolding isn''t meant to be permanent!) before you go inviting plugins like file_column to the party. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks a lot. One check made role. P.S. plugin also is working fine ;) But to get it working I spent a lot of time On 13 янв, 23:15, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:> On Jan 13, 2008, at 3:51 PM, sublime wrote: > > > I''m newbie. Please, help. I suppose it''s easy :) > > I have admin controller which is working ok and with usual controller > > I have trouble. > > This is app/controllers/team_controller.rb > > ____________________________________________ > > class TeamController < ApplicationController > > def show > > @team = Team.find(params[:id]) > > end > > end > > ___________________________________________ > > > And in app/controllers/admin/teams_controller.rb "Show" function is > > absolutely same. > > Are you defining Admin::TeamsController in that file? > > > > > Then, app/views/admin/teams/show.rhtml looks like > > <% for column in Team.content_columns %> > > <p> > > <% if column.human_name != "Image" %> > > <b><%= column.human_name %>:</b> <%=h @team.send(column.name) %> > > <% else %> > > <%= image_tag url_for_file_column :"team", :"image" %> > > <% end %> > > </p> > > <% end %> > > But when I try to use this code in app/views/team/show.rhtml I get an > > error: > > " Showing app/views/team/show.rhtml where line #6 raised: > > You have a nil object when you didn''t expect it! > > You might have expected an instance of Array. > > The error occurred while evaluating nil.split" > > I assume that @team.image is perhaps nil? > > Try this and see if you begin to understand what your code is doing: > > <% if column.human_name != "Image" %> > <b><%= column.human_name %>:</b> <%=h @team.send(column.name) %> > <% elsif @team.image.nil? %> > <span>Oops! The image is nil</span> > <% else %> > <%= image_tag url_for_file_column :"team", :"image" %> > <% end %> > > You really should understand what''s happening with the scaffold code > (and replace it with your actual code, scaffolding isn''t meant to be > permanent!) before you go inviting plugins like file_column to the > party. > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---