Adding columns / conditional view

I’m fairly new to RoR so go easy on me. I’ve worked through the depot
application and now I’m just trying to do some hacking so I can
understand it all a little more.

First question: I want to add a column to my database schema. Do I have
to reinstantiate the scaffold ( $> ruby script/generate scaffold Admin
) in order to have the fields show up on the site? I’m trying to add an
address column.

Second question: In an authenticate method, I want to view only admins
who have not been activated. This is not part of the depot application.
I created a scaffold of Admin which has a column in the admins table
that is either set to 1 or 0. 1 means active, 0 means inactive. I want
to be able to use the authorize.rhtml to view only admins who have
active = 0. Where do I do that?

here is the code for reference (it’s the list.rhtml code from a
scaffold generation):
<%

for admin in @admins %>

<% for column in Admin.content_columns %> <%=h admin.send(column.name) %> <% end %> <%= link_to 'Show', :action => 'show', :id => admin %> <%= link_to 'Edit', :action => 'edit', :id => admin %> <%= link_to 'Destroy', { :action => 'destroy', :id => admin }, :confirm => 'Are you sure?', :post => true %> <% end %>

<%= link_to ‘Previous page’, { :page => @admin_pages.current.previous }
if @admin_pages.current.previous %>
<%= link_to ‘Next page’, { :page => @admin_pages.current.next } if
@admin_pages.current.next %>


<%= link_to ‘New admin’, :action => ‘new’ %>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs