Help with scaffolds


#1

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?


#2

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


#3

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!


#4

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


#5

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.


#6

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

here

.

try to load the page again and see if “here” is displayed.


#7

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)?


#8

I have restarted my webrick server with no luck and here is what is in
my list.rhtml file:

Listing people

<% for column in Person.content_columns %> <% end %>

<% for person in @people %>

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

<%= 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 %>


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

Should I post my table structure?


#9

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!


#10

Ill try all that now, ill post more soon.


#11

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!