Help

I am working on a web app that attaches to a MySQL database.

I can add users through the admin_controller just fine without
“before_filter :authorize”

I need that statement obviously. When I try to login with my admin
password I get this

NoMethodError in Login#index

Showing app/views/login/index.rhtml where line #9 raised:

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each

Extracted source (around line #9):

6:

<%= column.human_name %>
7: <% end %>
8:
9: <% for account in @accounts %>
10:
11: <% for column in Account.content_columns %>
12: <%=h account.send(column.name) %>

RAILS_ROOT: ./script/…/config/…
Application Trace | Framework Trace | Full Trace

#{RAILS_ROOT}/app/views/login/index.rhtml:9:in _run_rhtml_login_index' -e:4:inload’
-e:4

Any suggestions would be appreciated.

Any suggestions would be appreciated.

Either there are no @accounts being returned or haven’t setup the
@accounts instance variable in your controller.

Try putting a condition before the loop that checks to see if there are
any accounts in @accounts like:

<%if @accounts.nil?%>
no accounts or account instance var
<%else%>
I have this many accounts: <%[email protected]%>
#your stuff here
<%end%>

David C. wrote:

Any suggestions would be appreciated.

Either there are no @accounts being returned or haven’t setup the
@accounts instance variable in your controller.

Try putting a condition before the loop that checks to see if there are
any accounts in @accounts like:

<%if @accounts.nil?%>
no accounts or account instance var
<%else%>
I have this many accounts: <%[email protected]%>
#your stuff here
<%end%>

Thanks a lot David! I was able to get this going. Thank you.