Rails is throwing this error
C:/Ruby/Depot/app/views/products/index.html.erb:28: syntax error,
unexpected tSTRING_BEG, expecting keyword_do or ''{'' or
''(''
...er.privilege == 50 ? {link_to ''Show'', product} :
''a'' );@out...
in line
<%= current_user.privilege == 50 ? {link_to ''Show'',
product} : ''a'' %>
current_user at ApllicationController
def current_user
return unless session[:user_id]
@current_user ||= User.find_by_id(session[:user_id])
end
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Nov 20, 10:04 pm, "Jose tomas R." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Rails is throwing this error > > C:/Ruby/Depot/app/views/products/index.html.erb:28: syntax error, > unexpected tSTRING_BEG, expecting keyword_do or ''{'' or ''('' > ...er.privilege == 50 ? {link_to ''Show'', product} : ''a'' );@out... > > in line > > <%= current_user.privilege == 50 ? {link_to ''Show'', product} : ''a'' %>I think you meant those to be () rather than {} Fred> > current_user at ApllicationController > > def current_user > return unless session[:user_id] > @current_user ||= User.find_by_id(session[:user_id]) > end > > -- > Posted viahttp://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
i notice, thanks
i use that line too mucho on my code so i made on ApplicationControlller
def privilege
(session[:user_id].exist? && session[:user_id].privilege == 50) ?
true : false
end
and on the actual page i put
<%= :privilege ? link_to(''Edit'',
edit_product_path(product)) : "" %>
but it doesnt work
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sat, Nov 20, 2010 at 5:22 PM, Jose tomas R. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> i notice, thanks > i use that line too mucho on my code so i made on ApplicationControlller > > def privilege > (session[:user_id].exist? && session[:user_id].privilege == 50) ? > true : false > end > > > and on the actual page i put > > <%= :privilege ? link_to(''Edit'', edit_product_path(product)) : "" %> > > but it doesnt work >There might be other issues, but the reason you can not access it is that you either need to put it in a helper (app/helpers), *or* make your code in the application controller look like: helper_method :privelige def privelige # your code here end> > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
i put it like a helper on AplicationController but still doesnt work -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Nov 20, 11:22 pm, "Jose tomas R." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> def privilege > (session[:user_id].exist? && session[:user_id].privilege == 50) ? > true : false > end > > and on the actual page i put > > <%= :privilege ? link_to(''Edit'', edit_product_path(product)) : "" %> > > but it doesnt workYou''ve got a stray : in front of privilege Fred> > -- > Posted viahttp://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
thanks -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.