On May 22, 2:55 am, Colin Law <[email protected]> wrote:
> On 22 May 2011 07:41, John shelfer <[email protected]> wrote:
>
>
>
>
>
>
>
>
>
>
>
> > On May 21, 2:45 pm, Frederick Cheung <[email protected]>
> > wrote:
> >> On May 21, 4:22 pm, John shelfer <[email protected]> wrote:
>
> >> > On May 21, 5:13 am, Colin Law <[email protected]> wrote:
>
> >> > yes i added a resource and now router.rb look likes but same issue
> >> > is still there
>
> >> > Check::Application.routes.draw do
> >> > get "posts/index"
> >> > resources :post
>
> >> resources should be plural, ie resources :posts
> > Thank you very much.It worked.But now i got another error in
> > following file ,it says
>
> > "undefined method `name' for #<Post id: nil, created_at: nil,
> > updated_at: nil>"
>
> Look at the error and try and work out what it means. There should
> also be an indication of which line generated the error.
Error is generated at link 8 in following code.
<%= link_to 'New Post', new_post_path%>
<%= form_for(@post) do |f| %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :content %><br />
<%= f.text_area :content %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
Posts_controller.rb file looks like:
class PostsController < ApplicationController
def try
@post = Post.new
end
def create
@post = Post.new(params[:post])
respond_to do |format|
end
end
end
John
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.