Comments (8)
Which tutorial was this in?
from curriculum.
Steve,
It was in JSBlogger: http://tutorials.jumpstartlab.com/projects/jsblogger.html
from curriculum.
Hm. article_path
should be correct there. Can you show me what your routes.rb file has in it?
from curriculum.
Thanks for looking into this Steve.
My routes.rb file is:
Jsblogger::Application.routes.draw do
#create a resource names articles
resources :comments
resources :articles
The priority is based upon order of creation:
first created -> highest priority.
Sample of regular route:
match 'products/:id' => 'catalog#view'
Keep in mind you can assign values other than :controller and :action
Sample of named route:
match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
This route can be invoked with purchase_url(:id => product.id)
Sample resource route (maps HTTP verbs to controller actions automatically):
resources :products
Sample resource route with options:
resources :products do
member do
get 'short'
post 'toggle'
end
collection do
get 'sold'
end
end
Sample resource route with sub-resources:
resources :products do
resources :comments, :sales
resource :seller
end
Sample resource route with more complex sub-resources
resources :products do
resources :comments
resources :sales do
get 'recent', :on => :collection
end
end
Sample resource route within a namespace:
namespace :admin do
# Directs /admin/products/* to Admin::ProductsController
# (app/controllers/admin/products_controller.rb)
resources :products
end
You can have the root of your site routed with "root"
just remember to delete public/index.html.
root :to => 'welcome#index'
See how all your routes lay out with "rake routes"
This is a legacy wild controller route that's not recommended for RESTful applications.
Note: This route will make all actions in every controller accessible via GET requests.
match ':controller(/:action(/:id(.:format)))'
end
Here are my routes:
Ping:jsblogger admin$ rake routes
comments GET /comments(.:format) {:action=>"index", :controller=>"comments"}
POST /comments(.:format) {:action=>"create", :controller=>"comments"}
new_comment GET /comments/new(.:format) {:action=>"new", :controller=>"comments"}
edit_comment GET /comments/:id/edit(.:format) {:action=>"edit", :controller=>"comments"}
comment GET /comments/:id(.:format) {:action=>"show", :controller=>"comments"}
PUT /comments/:id(.:format) {:action=>"update", :controller=>"comments"}
DELETE /comments/:id(.:format) {:action=>"destroy", :controller=>"comments"}
articles GET /articles(.:format) {:action=>"index", :controller=>"articles"}
POST /articles(.:format) {:action=>"create", :controller=>"articles"}
new_article GET /articles/new(.:format) {:action=>"new", :controller=>"articles"}
edit_article GET /articles/:id/edit(.:format) {:action=>"edit", :controller=>"articles"}
article GET /articles/:id(.:format) {:action=>"show", :controller=>"articles"}
PUT /articles/:id(.:format) {:action=>"update", :controller=>"articles"}
DELETE /articles/:id(.:format) {:action=>"destroy", :controller=>"articles"}
from curriculum.
of course!
article GET /articles/:id(.:format) {:action=>"show", :controller=>"articles"}
Yeah. Should be article_path(article). How strange. Could you maybe upload the app to a repo so I could play around with it?
from curriculum.
Steve,
Try this: https://github.com/khristian/test
This is the first time I've created a repo so let me know if this isn't what you need.
Thanks again.
from curriculum.
That's great! Looking at it now.
from curriculum.
Turns out the problem is unrelated, and this is just a really, really poor error message:
https://github.com/khristian/test/blob/master/app/controllers/comments_controller.rb#L4
This should be Comment.new(params[:comment])
, because params[:article]
is nil. When it's nil, and you try to give nil to comment_path
, it throws that error. Which is dumb.
Let me know if I can help clear up any confusion about this.
from curriculum.
Related Issues (20)
- eventmanager: Sunlight Labs API key not required
- my mistake HOT 1
- NameError in AuthorSessionsController
- I0 Template is Missing error doesn't appear
- Typo in section I3
- Missing the part where edit and index page uses a common partial
- syntax error, unexpected tIDENTIFIER in SessionsController#create HOT 1
- at I2 I get undefined method when I type a.comments in command. HOT 1
- Blogger 2 - I3 Tagging, final step
- Blogger2: No mention of 'dependent: :delete_all', which seems necessary
- not-related
- not-related
- Blogger: Unclear section "Fragile Controllers"
- Blogger2: bin/rails generate model Article does not create any of the files that the article says it should. HOT 2
- Ruby version required in Installation is outdated
- Broken link to sample image in I4 HOT 1
- What ruby version do you guys recommend using for this tutorial?
- My Feedback after finishing the Tutorial
- Event Manager Markdown
- Improve upon argument for using a one-to-one relationship
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from curriculum.