Hello everyone,
I am following the Practical Rails: Social Networking
sites book. In chapter 7 photo gallery I am getting a
NoMethodError in Pages#show
Showing layouts/_menu.rhtml where line #12 raised:
undefined method `new_entry_path’ for #ActionView::Base:0x52fa56c
Extracted source (around line #12):
9: <% if is_logged_in? %>
10:
Logged in as: <%= logged_in_user.username %>
11:
<%= link_to ‘My Profile’, edit_user_path(logged_in_user)
%>
12:
<%= link_to ‘New Blog Post’, new_entry_path(:user_id =>
logged_in_user) -%>
13:
<%= link_to ‘Upload Photo’, user_new_photo_path(:user_id
=> logged_in_user) -%>
14:
<%= link_to ‘Logout’, {:controller => ‘account’, :action
=> ‘logout’}, :method => :post %>
15: <% else %>
I am using rails 2.0.2 over windows vista. Can someone please explain
me whats wrong?
Do you have a controller named entries? Do you have a route set up for
it:
map.resources :entries
On Jan 22, 2008 8:52 AM, stranger [email protected] wrote:
undefined method `new_entry_path’ for #ActionView::Base:0x52fa56c
=> logged_in_user) -%>
14:
<%= link_to ‘Logout’, {:controller => ‘account’, :action
=> ‘logout’}, :method => :post %>
15: <% else %>
I am using rails 2.0.2 over windows vista. Can someone please explain
me whats wrong?
–
Ryan B.
Feel free to add me to MSN and/or GTalk as this email.
Ya I have a ‘entries_controller.rb’ where index, new create, edit and
destroy are defined. and in routes.rb
map.resources :articles, :collection => {:admin => :get}
map.resources :users, :member => { :enable => :put } do |users|
users.resources :roles
users.resources :entries do |entry|
entry.resources :comments
end
users.resources :photos, :name_prefix => ‘user_’, :controller =>
‘user_photos’
end
map.resources :articles, :collection => {:admin => :get}
This is the ‘entries’ in config.rb. I am creating a new blog post that
is entry…
You’re doing map.resources :articles yet you’re trying to do
new_entry_path.
Try new_article_path instead.
On Jan 22, 2008 9:04 AM, stranger [email protected] wrote:
map.resources :entries
sites book. In chapter 7 photo gallery I am getting a
10:
Logged in as: <%= logged_in_user.username %>
I am using rails 2.0.2 over windows vista. Can someone please explain
me whats wrong?
–
Ryan B.http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.
–
Ryan B.
Feel free to add me to MSN and/or GTalk as this email.
Um, in that case it’s new_user_entry_path because entries is nested
inside
users. also it should be |user| not |users|.
Have a read of this:
On Jan 22, 2008 9:19 AM, stranger [email protected] wrote:
On Jan 22, 2008 9:04 AM, stranger [email protected] wrote:
On Jan 21, 2:29 pm, “Ryan B.” [email protected] wrote:
I am following the Practical Rails: Social Networking
user_new_photo_path(:user_id
–
Ryan B.http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.
–
Ryan B.http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.
–
Ryan B.
Feel free to add me to MSN and/or GTalk as this email.
I’m sorry for the late reply…I am still getting the same error.
<% if is_logged_in? %>
Logged in as: <%= logged_in_user.username %>
<%= link_to ‘My Profile’, edit_user_path(logged_in_user) %></
li>
<%= link_to ‘New Blog Post’, new_entry_path(:user_id =>
logged_in_user) -%>
<%= link_to ‘Upload Photo’, user_new_photo_path(:user_id =>
logged_in_user) -%>
<%= link_to ‘Logout’, {:controller => ‘account’, :action =>
‘logout’}, :method => :post %>
<% else %>
<%= link_to ‘Signup’, :controller => ‘users’, :action => ‘new’
%>
<%= link_to ‘Login’, :controller => ‘account’, :action =>
‘login’ %>
<% end %>
When I try to reach the page without logging I am able to see the
localhost:3000/photos and index. But when I login and the above block
of code gets executed I am getting the error.
undefined method `new_entry_path’ for #ActionView::Base:0x50d9f6c
Because you’re STILL calling new_entry_path when I told you it should be
new_user_entry_path(@user)
either that or define map.resources :entries inside of your
routes.rboutside of the user block.
On Jan 22, 2008 2:35 PM, stranger [email protected] wrote:
logged_in_user) -%>
localhost:3000/photos and index. But when I login and the above block
end
new_entry_path.
On Jan 21, 2:29 pm, “Ryan B.” [email protected] wrote:
Hello everyone,
#ActionView::Base:0x52fa56c
new_entry_path(:user_id
I am using rails 2.0.2 over windows vista. Can someone please
–
Ryan B.http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.
–
Ryan B.
Feel free to add me to MSN and/or GTalk as this email.