Regards,
Seeni Rafiyullah Khan A,



On Thu, Sep 20, 2012 at 4:36 PM, ruby rails <li...@ruby-forum.com> wrote:

> Rafi A wrote in post #1076789:
> > Hi,
> >
> > See my comments inline:
> >
> > Regards,
> > Seeni Rafiyullah Khan A,
> > <srk...@apigee.com>*In Every moment, thank God.*
> >
> >
> >
> > On Thu, Sep 20, 2012 at 4:15 PM, ruby rails <li...@ruby-forum.com>
> > wrote:
> >
> >>
> >>
> >>
> >>
> >>
> > You are trying to get the admin name from the symbol :( and hence you
> > are
> > getting the issue.
> >
> >  In the controller, assign the resultant admin record to the instance
> > variable as below:
> >
> > *@admin=Admin.find_by_email(params[:session][:email].downcase)*
> >
> > In your view page, use as below:
> >
> > *<%="Hi"%><%= @admin.name%> *
> > *
> > *
>  HI,
>
> I tried with the the below code. But still getting the same result in
> view page as "undefined method `name' for nil:NilClass"
>
>  def create
>    @admin=Admin.find_by_email(params[:session][:email].downcase)
>        user=User.find_by_email(params[:session][:email].downcase)
>      if user && user.authenticate(params[:session][:password])
>       redirect_to(dashboard_path(:user=>user))
>     else
>       redirect_to(admins_index_path(:current_admin=>@admin))
>     end
>   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@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> This is different issue. Check whether there is an admin in your db with
the email address which you are passing through *params[:session][:email]*
? And for the backward compatibility, use the below logic in your view so
that you can get the clarity in what you are doing :)

<% if !@admin.blank? %>
<%="Hi"%><%= @admin.name%>
<%else%>
no records
<%end%>

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to