Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby on rails model and controllers inside of different namespaces
    text
    copied!<p>OK. This is insane.</p> <p>I'm new to RoR and I really want to get into it as everything about it that I have seen so far makes it more appealing to the type of work that I do.</p> <p>However, I can't seem to accomplish a <em>very</em> simple thing with RoR.</p> <p>I want these controlers:</p> <pre><code>/admin/blog/entries (index/show/edit/delete) /admin/blog/categories (index/show/edit/delete) /admin/blog/comments (index/show/edit/delete) ... and so on </code></pre> <p>And these models:</p> <pre><code>Blog::Entry (table: blog_entries) Blog::Category (table: blog_categories) Blog::Comments (table: blog_comments) ... and so on </code></pre> <p>Now, I have already gone though quite a bit of misery to make this work. My first attempt was with generating scaffolding (I'm using 2.2.2). I generated my scaffolding, but had to move my model, then fix the references to the model in my controller (see <a href="https://stackoverflow.com/questions/903258/ruby-on-rails-model-inside-namespace-cant-be-found-in-controller">Ruby on Rails model inside namespace can&#39;t be found in controller</a>).</p> <p>That is already a big of a pain, but hey, I got it to work. Now though form_for won't work and I cannot figure out how to use the url helpers (I have no idea what these are called... they are the automatically generated methods that return URLs to controllers associated with a model). I cannot figure out what their name is. My model is Blog::Entries. I have tried to mess with the route.rb's map's resource method, but no luck. When I attempt to use form_for with my model, I get this error </p> <pre><code>undefined method `blog_entries_path' for #&lt;ActionView::Base:0xb6848080&gt; </code></pre> <p>Now. This is really quite frustrating. I am not going to completely destroy my code's organization in order to use this framework, and if I cannot figure out how to accomplish this simple task (I have been researching this for at least 5 hours) then I simply cannot continue.</p> <p>Are there any ideas on how to accomplish this?</p> <p>Thanks</p> <p><strong>EDIT</strong></p> <p>Here are my routes:</p> <pre><code> admin_blog_entries GET /admin_blog_entries {:controller=&gt;"admin_blog_entries", :action=&gt;"index"} formatted_admin_blog_entries GET /admin_blog_entries.:format {:controller=&gt;"admin_blog_entries", :action=&gt;"index"} POST /admin_blog_entries {:controller=&gt;"admin_blog_entries", :action=&gt;"create"} POST /admin_blog_entries.:format {:controller=&gt;"admin_blog_entries", :action=&gt;"create"} new_admin_blog_entry GET /admin_blog_entries/new {:controller=&gt;"admin_blog_entries", :action=&gt;"new"} formatted_new_admin_blog_entry GET /admin_blog_entries/new.:format {:controller=&gt;"admin_blog_entries", :action=&gt;"new"} edit_admin_blog_entry GET /admin_blog_entries/:id/edit {:controller=&gt;"admin_blog_entries", :action=&gt;"edit"} formatted_edit_admin_blog_entry GET /admin_blog_entries/:id/edit.:format {:controller=&gt;"admin_blog_entries", :action=&gt;"edit"} admin_blog_entry GET /admin_blog_entries/:id {:controller=&gt;"admin_blog_entries", :action=&gt;"show"} formatted_admin_blog_entry GET /admin_blog_entries/:id.:format {:controller=&gt;"admin_blog_entries", :action=&gt;"show"} PUT /admin_blog_entries/:id {:controller=&gt;"admin_blog_entries", :action=&gt;"update"} PUT /admin_blog_entries/:id.:format {:controller=&gt;"admin_blog_entries", :action=&gt;"update"} DELETE /admin_blog_entries/:id {:controller=&gt;"admin_blog_entries", :action=&gt;"destroy"} DELETE /admin_blog_entries/:id.:format {:controller=&gt;"admin_blog_entries", :action=&gt;"destroy"} home / {:action=&gt;"index", :controller=&gt;"index"} /:controller/:action/:id /:controller/:action/:id.:format </code></pre> <p>That dosn't look right. Here is my routes.rb (comments removed):</p> <pre><code>ActionController::Routing::Routes.draw do |map| map.resources :admin_blog_entries map.home '', :controller =&gt; 'index' map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload