uninitialized constant ApplicationController
please help to solve it and understand..:)
thanks
amritpalpathakgne.wordpress.com
there should be in app/controllers/admin/posts_controller.rb
class Admin::PostController < ApplicationController
end
tom
> --
> 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 rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
--
===============================================================================
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz
===============================================================================
show us the source of one controller at least
ya sure.
there should be in app/controllers/admin/posts_controller.rb
class PostsController < ApplicationController#def click#enddef newenddef show@show = Post.find(params[:id])enddef index@post = Post.newenddef create@post = Post.new(params[:post])respond_to do |format|if @post.saveformat.html{ redirect_to(@post, :notice => 'Post was successfully created.') }endend
end
1. "pseudo" namespace from routes
in routes.rb
map '/namespace/:controller/:action/:id'
and then you'll have all the controllers in /app/controllers w/o any namespace in class name
2. namespaced in source
this one follows my previous example, eg
/app/controllers/namespace/cars_controller.rb
class Namespace::CarsController < ApplicationController
end
tom
sure.. when you want to use namespace, having two options
1. "pseudo" namespace from routes
in routes.rb
map '/namespace/:controller/:action/:id'
and then you'll have all the controllers in /app/controllers w/o any namespace in class name
2. namespaced in source
this one follows my previous example, eg
/app/controllers/namespace/cars_controller.rb
if you have posts_controller in /app/controllers/admin/posts_controller.rb
then you MUST have this namespace in your class name
class PostsController < ApplicationController <- WRONG
class Admin::PostsController < ApplicationController <- RIGHT
and in your routes.rb (for rails3) have
namespace :admin do
resources :posts
end
tom
I said...
if you have posts_controller in /app/controllers/admin/posts_controller.rb
then you MUST have this namespace in your class name
class PostsController < ApplicationController <- WRONG
class Admin::PostsController < ApplicationController <- RIGHT
done..:)
and in your routes.rb (for rails3) have
namespace :admin do
resources :posts
end
On Mon, Jun 20, 2011 at 1:23 PM, Tom Meinlschmidt <to...@meinlschmidt.com> wrote:
I said...
if you have posts_controller in /app/controllers/admin/posts_controller.rb
then you MUST have this namespace in your class name
class PostsController < ApplicationController <- WRONGokdone..:)
class Admin::PostsController < ApplicationController <- RIGHT
and in your routes.rb (for rails3) have
namespace :admin do
resources :posts
enddone.....:)still "localhost:3000/admin/posts" gives the errorRouting Error
sir this file was in app/controller/application_controller.rb before using namespacing.Now i hadcopied it to app/view/admin along with posts_controller.rb
--
That's the problem. Don't move application_controller.rb fileIt should always be under app/controllers folder not in the namespaced folder.Move it back and your error should go away
thanks sir .Thats error is solved but another one came w hen i browse to "localhost:3000/admin/posts".
Missing template admin/posts/index with {:handlers=>[:rhtml, :rxml, :erb, :builder, :rjs], :formats=>[:html], :locale=>[:en, :en]} in view paths "/home/amrit/check/app/views"
The index.html.erb file exist already in /app/view/posts/index.html.erb.
should i make a new directory in /app/views and move the "posts" directory inside it same as namespacing in controller??
Thank you very much for support.
--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yes. Create a new directory "admin" under app/views and move "posts" directory into that one.
again bad luck.I did as you said.
new error
Showing /home/amrit/check/app/views/admin/posts/index.html.erb where line #2 raised:
No route matches {:controller=>"posts", :action=>"new"}
I did everything as previous before namespacing ,it was working.The file new.html.erb exist in same directory.This file looks :
<%= 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 align="center">
<div class="actions">
<%= f.submit %>
</div>
</div>
<div class="field">
<%= f.label :sign %><br />
<%= f.text_field :sign %>
</div>
<div class="field">
<%= f.label :value %><br />
<%= f.text_field :value %>
</div>
<% end %>
<%= submit_tag "Test me!", :type => 'button', :onclick => 'alert("It works!")' %>
<br>
<%= submit_tag "Click me", :type => 'button' %>
<%= button_to "Great", :action => "click"%>
<%= button_to "click me", :action => "work"%>
here if i removed 1st time just to test ,the next line gives the error:
No route matches {:controller=>"posts"}
I think we are missing something to add or else.
thanks
amritpalpathakgne.wordpress.com
--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
All your routes will need to change as per the named scopenew_post_path should be changed to new_admin_post_pathform_for(@post) should be changed to form_for [:admin, @post]
and so on
--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
In which controller do you have the "click" action defined?If it's in the same controller
then you need to define it in your routes too.
namespace :admin doresources :posts, :collection => {:click => :post}end
Did exactly
And in the code you had posted, the click method in your controller was commented, so that may be the issue as well
--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try this thenno it haven't work too.
--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Can you paste the code from your routes file here?
Check::Application.routes.draw do# get "gne/clg"get "posts/index"#resources :posts, :module => "admin"namespace "admin" doresources :posts ,:collection =>{:click => :post}end#working right#resources :posts do#end#working rightroot :to => "posts#click"root :to => "posts#work"#get 'posts/click'#ActionController::Routing::Routes.draw do |map|#map.root :controller => "posts", :action => "click"#end#ActionController::Routing::Routes.draw do |map|#map.root :controller => "posts", :action => "work"#endend
Can you explain what these two routes are doing?
Colin
On 21 June 2011 14:16, amritpal pathak <amritpa...@gmail.com> wrote:Can you explain what these two routes are doing?
>
>
> On Tue, Jun 21, 2011 at 9:09 AM, Chirag Singhal <chirag....@gmail.com>
> wrote:
>>
>> Can you paste the code from your routes file here?
>>
>> Check::Application.routes.draw do
>> # get "gne/clg"
>> get "posts/index"
>> #resources :posts, :module => "admin"
>> namespace "admin" do
>> resources :posts ,:collection =>{:click => :post}
>> end
>> #working right
>> #resources :posts do
>> #end
>> #working right
>> root :to => "posts#click"
>> root :to => "posts#work"
--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I have lost track of how many times Aritpal Pathak has been advised to
read that. Also you might like to try getting him to post the result
of rake routes.
Colin
ROFLMAO :-)
Sorry, I sent you the rails 2.3 way of routing.It should have been like this:namespace "admin" doresources :posts docollection dopost :clickendend
And as Colin said, you can't have two "root" routes for your app. Keep one of them and remove the other one.
Also, you may want to read up more on routing.Here's a link to official guide, which does a great job of explaining how routing works in rails 3
thats what i am following and i got this error from this tutorial.BTW thanks again.......:P
On 21 June 2011 14:44, Chirag Singhal <chirag....@gmail.com> wrote:I have lost track of how many times Aritpal Pathak has been advised to
> Also, you may want to read up more on routing.
> Here's a link to official guide, which does a great job of explaining how
> routing works in rails 3
> http://guides.rubyonrails.org/routing.html
read that.
That is good. You could try and help Joanne(Yennie) with her problems
if you wished to make a contribution back to the Rails Community.
Colin
That is good.On 21 June 2011 17:06, amritpal pathak <amritpa...@gmail.com> wrote:
>
>
> On Tue, Jun 21, 2011 at 9:59 AM, Colin Law <cla...@googlemail.com> wrote:
>>
>> On 21 June 2011 14:44, Chirag Singhal <chirag....@gmail.com> wrote:
>> > Also, you may want to read up more on routing.
>> > Here's a link to official guide, which does a great job of explaining
>> > how
>> > routing works in rails 3
>> > http://guides.rubyonrails.org/routing.html
>>
>> I have lost track of how many times Aritpal Pathak has been advised to
>> read that.
>
> Sir this time i am your advice and reading it .i got the error while
> following section number 2.6 on namespacing.Thats why i posted here and now
> got my answer.Now will move ahead on tutorial.
> Again thanks to all
You could try and help Joanne(Yennie) with her problems
if you wished to make a contribution back to the Rails Community.
Have you not seen her postings? One of the best ways to learn about a
subject is to read all the threads on the forum and for any questions
where you understand the question then make sure you understand the
answers. In no time you will find yourself answering questions. Her
thread subject is "Error of undefined method".
Colin
and for any questions
where you understand the question then make sure you understand the
answers. In no time you will find yourself answering questions. Her
thread subject is "Error of undefined method".