Forum: Ruby on Rails Help with scaffolds

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Stuart L. (Guest)
on 2006-12-23 19:21
I have create a ruby application at http://wopmod.digitalcarnival.com
and have done all the database stuff and have even migrated tables and
now I have trioed creating the scaffolds for it but when I go to the
main scaffolds page for it, http://wopmod.digitalcarnival.com/people I
get an application error(rails) message yet when I go to say
http://wopmod.digitalcarnival.com/people/edit.rhtml it works, any ideas
as to why it doesnt work?
Shauna (Guest)
on 2006-12-23 23:20
Hi Stuart,

Do you have an index method in your people_controller.rb? If so, does it
look something like this?

  def index
    list
    render :action => 'list'
  end

The above method handles URLs that don't specify any other method, such
as http://wopmod.digitalcarnival.com/people.

Shauna
Stuart L. (Guest)
on 2006-12-23 23:57
Shauna wrote:
> Hi Stuart,
>
> Do you have an index method in your people_controller.rb? If so, does it
> look something like this?
>
>   def index
>     list
>     render :action => 'list'
>   end
>
> The above method handles URLs that don't specify any other method, such
> as http://wopmod.digitalcarnival.com/people.
>
> Shauna

This is my index:

class PeopleController < ApplicationController
  def index
    list
    render :action => 'list'
  end

  # GETs should be safe (see
http://www.w3.org/2001/tag/doc/whenToUseGet.html)
  verify :method => :post, :only => [ :destroy, :create, :update ],
         :redirect_to => { :action => :list }

  def list
    @person_pages, @people = paginate :people, :per_page => 10
  end

  def show
    @person = Person.find(params[:id])
  end

  def new
    @person = Person.new
  end

  def create
    @person = Person.new(params[:person])
    if @person.save
      flash[:notice] = 'Person was successfully created.'
      redirect_to :action => 'list'
    else
      render :action => 'new'
    end
  end

  def edit
    @person = Person.find(params[:id])
  end

  def update
    @person = Person.find(params[:id])
    if @person.update_attributes(params[:person])
      flash[:notice] = 'Person was successfully updated.'
      redirect_to :action => 'show', :id => @person
    else
      render :action => 'edit'
    end
  end

  def destroy
    Person.find(params[:id]).destroy
    redirect_to :action => 'list'
  end
end

Would it matter that I also have another scaffold called news. which is
also doing the same thing, and even when I go to
http://wopmod.digitalcarnival.com/list.rhtml I get the error. I dont
know whats going wrong!
Skeets (Guest)
on 2006-12-24 01:08
(Received via mailing list)
Stuart, ...people/show and ...people/list are also not being picked up.
 could you have you over ridden the basic scaffold and only completed
one of the views (edit)?
Stuart L. (Guest)
on 2006-12-24 01:12
Skeets wrote:
> Stuart, ...people/show and ...people/list are also not being picked up.
>  could you have you over ridden the basic scaffold and only completed
> one of the views (edit)?

I dont think so, all I did was ruby script/generate scaffold people

I know edit and new work if add the .rhtml extension
Skeets (Guest)
on 2006-12-24 01:24
(Received via mailing list)
Stuart, how did you set up the scaffold?  can you post the relevant
controller code and the command line script you used to generate the
scaffold?

i'm thinking that your rails application is getting lost because it
doesn't have a reference to and index (linking to an index.rhtml view)
in the People class.

good luck.
Skeets (Guest)
on 2006-12-24 02:24
(Received via mailing list)
Stuart, what does your list.rhtml file look like int he views
directory?  verify the name is "list.rhtml".

have you tried restarting webrick to see if it just isn't seeing
changes you've made?

if list,.rhtml exist and is in the views directory, you may want to
test out the connection.  delete everything in list.rhtml and type in
<p>here</p>.

try to load the page  again and see if "here" is displayed.
Stuart L. (Guest)
on 2006-12-24 13:17
Ill try all that now, ill post more soon.
Stuart L. (Guest)
on 2006-12-24 13:22
I have restarted my webrick server with no luck and here is what is in
my list.rhtml file:

<h1>Listing people</h1>

<table>
  <tr>
  <% for column in Person.content_columns %>
    <th><%= column.human_name %></th>
  <% end %>
  </tr>

<% for person in @people %>
  <tr>
  <% for column in Person.content_columns %>
    <td><%=h person.send(column.name) %></td>
  <% end %>
    <td><%= link_to 'Show', :action => 'show', :id => person %></td>
    <td><%= link_to 'Edit', :action => 'edit', :id => person %></td>
    <td><%= link_to 'Destroy', { :action => 'destroy', :id => person },
:confirm => 'Are you sure?', :post => true %></td>
  </tr>
<% end %>
</table>

<%= link_to 'Previous page', { :page => @person_pages.current.previous }
if @person_pages.current.previous %>
<%= link_to 'Next page', { :page => @person_pages.current.next } if
@person_pages.current.next %>

<br />

<%= link_to 'New person', :action => 'new' %>

Should I post my table structure?
Stuart L. (Guest)
on 2006-12-24 13:32


OK!!! I think I have found why it wont work, when I migrated the tables
only went into development yet my app environment is production! How can
I just put my tables in to all the other databases (test and
development) Im using mysql and have phpmyadmin!
Stuart L. (Guest)
on 2006-12-24 16:15
Stuart Loxton wrote:
>
>
>
> OK!!! I think I have found why it wont work, when I migrated the tables
> only went into development yet my app environment is production! How can
> I just put my tables in to all the other databases (test and
> development) Im using mysql and have phpmyadmin!

Ok I have everything working now, Thank You all!
This topic is locked and can not be replied to.