<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - SOLVED - Rails 3.2.11, Ransack and namespaced routes… Template missing]]></title>
		<link>http://railsforum.com/viewtopic.php?id=53749</link>
		<description><![CDATA[The most recent posts in SOLVED - Rails 3.2.11, Ransack and namespaced routes… Template missing.]]></description>
		<lastBuildDate>Tue, 05 Mar 2013 11:37:21 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: SOLVED - Rails 3.2.11, Ransack and namespaced routes… Template missing]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=160880#p160880</link>
			<description><![CDATA[<p>I solved it !<br />The problem was in my controller action...<br />I changed it to<br /></p><div class="codebox"><pre><code>@q = User.search(params[:q])
@users = @q.result(:distinct =&gt; true).paginate(:per_page =&gt; 5, :page =&gt; params[:page])
render &#039;index&#039;</code></pre></div><p>and now all is fine. Thanks for your time</p>]]></description>
			<author><![CDATA[dummy@example.com (anso)]]></author>
			<pubDate>Tue, 05 Mar 2013 11:37:21 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=160880#p160880</guid>
		</item>
		<item>
			<title><![CDATA[Re: SOLVED - Rails 3.2.11, Ransack and namespaced routes… Template missing]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=160873#p160873</link>
			<description><![CDATA[<p>Hi James<br />Thanks for answering. I know the problem comes from the routes and Rails is looking for a &#039;search&#039; in mines. <br />My problem is with the &#039;virtual&#039; routes .<br />What I don&#039;t understand is why this one</p><div class="codebox"><pre><code>resources :users, :controller =&gt; &quot;frontend/users&quot;, only: [:new, :create] do
    member do
      get &quot;activate&quot;
    end
  end</code></pre></div><p>works fine even if there is no &#039;activate.html.erb&#039;</p><p>and in this one </p><div class="codebox"><pre><code>namespace :backstage do
    match &#039;&#039;, to: &quot;dashboard#index&quot;, as: &#039;/&#039;
    get &#039;users/active&#039; =&gt; &#039;users#active&#039;, :as =&gt; &#039;active_users&#039;
    resources :users do
      collection do
        match &#039;search&#039; =&gt; &#039;users#search&#039;, :via =&gt; [:get, :post], :as =&gt; :search
      end
      resources :profiles
    end
  end</code></pre></div><p>Why the part <br /></p><div class="codebox"><pre><code>    resources :users do
      collection do
        match &#039;search&#039; =&gt; &#039;users#search&#039;, :via =&gt; [:get, :post], :as =&gt; :search
      end</code></pre></div><p>does not work... I supposed that the block &quot;collection do...end&quot; act as the block &quot;member do...end&quot;&nbsp; but it seems that is not the case... Probably my fault but I don&#039;t understand why....</p><p>Cheers</p>]]></description>
			<author><![CDATA[dummy@example.com (anso)]]></author>
			<pubDate>Tue, 05 Mar 2013 08:57:55 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=160873#p160873</guid>
		</item>
		<item>
			<title><![CDATA[Re: SOLVED - Rails 3.2.11, Ransack and namespaced routes… Template missing]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=160858#p160858</link>
			<description><![CDATA[<p>The error is &quot;Missing template backstage/users/search&quot; which means it can not find a search.html.erb view template in your views/backstage/users folder<br />Create one, fill it with whatever it need filling with and your error will go. Hopefully not to be replaced by a new error <img src="http://railsforum.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (jamesw)]]></author>
			<pubDate>Mon, 04 Mar 2013 19:47:56 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=160858#p160858</guid>
		</item>
		<item>
			<title><![CDATA[SOLVED - Rails 3.2.11, Ransack and namespaced routes… Template missing]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=160856#p160856</link>
			<description><![CDATA[<p>Fairly new to Rails so sorry if the question seems obvious...</p><p>I have a User model in app/models<br /></p><div class="codebox"><pre><code>class User &lt; ActiveRecord::Base
  attr_accessible :email, :password, :password_confirmation, :remember_me, :created_by, :active, :blocked, :profile_attributes
  has_secure_password


  # relations
  has_one :profile, :dependent =&gt; :destroy, :inverse_of =&gt; :user
  accepts_nested_attributes_for :profile

 [...]</code></pre></div><p>And a controller in controllers/backstage/users_controller.rb<br /></p><div class="codebox"><pre><code>class Backstage::UsersController &lt; ApplicationController

  def index
    #@users = User.all
    @q = User.search(params[:q])
    @users = @q.result(:distinct =&gt; true).paginate(:per_page =&gt; 5, :page =&gt; params[:page])
    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @users }
    end
  end

[...]

# Search
  def search
    index
    render :index
  end
end</code></pre></div><p>And the routes.rb file is<br /></p><div class="codebox"><pre><code>Novaxones::Application.routes.draw do

  resources :sessions, only: [:new, :create, :destroy]

  resources :users, :controller =&gt; &quot;frontend/users&quot;, only: [:new, :create] do
    member do
      get &quot;activate&quot;
    end
  end


  resources :forgotten_passwords, :controller =&gt; &quot;frontend/forgotten_passwords&quot;, except: [:destroy, :show]
  resources :activation_requests, :controller =&gt; &quot;frontend/activation_requests&quot;, only: [:new, :create]

  match &#039;/forgotten_password_request&#039;, to: &#039;frontend/forgotten_passwords#new&#039;
  match &#039;/logout&#039;, to: &#039;sessions#destroy&#039;, via: :delete
  match &#039;/login&#039;, to: &#039;sessions#new&#039;
  match &#039;/registration&#039;, to: &#039;frontend/users#new&#039;
  match &#039;/contact&#039;, to: &#039;frontend/base_pages#contact&#039;
  match &#039;/about&#039;, to: &#039;frontend/base_pages#about&#039;
  match &#039;/help&#039;, to: &#039;frontend/base_pages#help&#039;
  match &#039;/site-map&#039;, to: &#039;frontend/base_pages#sitemap&#039;, as: &#039;sitemap&#039;

  namespace :backstage do
    match &#039;&#039;, to: &quot;dashboard#index&quot;, as: &#039;/&#039;
    get &#039;users/active&#039; =&gt; &#039;users#active&#039;, :as =&gt; &#039;active_users&#039;
    resources :users do
      collection do
        match &#039;search&#039; =&gt; &#039;users#search&#039;, :via =&gt; [:get, :post], :as =&gt; :search
      end
      resources :profiles
    end
  end


  root to: &#039;frontend/base_pages#home&#039;</code></pre></div><p>As you can see I use namespaced routes to have an admin panel (called backstage)</p><p>I use Ransack 0.7.2.&nbsp; When I search anything I always have the error :<br /></p><div class="codebox"><pre><code>Missing template backstage/users/search, application/search with {:locale=&gt;[:en], :formats=&gt;[:html], :handlers=&gt;[:erb, :builder, :coffee]}. Searched in: * &quot;C:/RailsApps/novaxones/app/views&quot;</code></pre></div><p>The index.html.erb is<br /></p><div class="codebox"><pre><code>&lt;div id=&quot;table-users-grid&quot;&gt;
  &lt;div id=&quot;grid-top-pagination&quot; class=&quot;row&quot;&gt;

    &lt;div class=&quot;span4&quot;&gt;&lt;%= will_paginate %&gt;&lt;/div&gt;
    &lt;div class=&quot;span4 page-entries-info&quot;&gt;&lt;%= page_entries_info %&gt;&lt;/div&gt;
    &lt;div id=&quot;search-area&quot; class=&quot;span4&quot;&gt;
      &lt;%= search_form_for @q, :url =&gt; search_backstage_users_path, :html =&gt; {:method =&gt; :post} do |sf| %&gt;
          &lt;div class=&quot;search-form-fields&quot;&gt;
            &lt;%= sf.text_field :email_cont, :placeholder =&gt; &#039;search users email contains&#039; %&gt;
          &lt;/div&gt;
          &lt;div class=&quot;actions&quot;&gt;&lt;%= sf.submit &quot;Search&quot; %&gt;&lt;/div&gt;
      &lt;% end %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id=&quot;management-area&quot; class=&quot;row&quot;&gt;
    &lt;table id=&quot;users-grid&quot; class=&quot;span10&quot;&gt;
      &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;&lt;%= link_to &#039;UID&#039;, :sort =&gt; &quot;id&quot; %&gt;&lt;/th&gt;
        &lt;th&gt;&lt;%= link_to &#039;Last name&#039;, :sort =&gt; &quot;profiles.last_name&quot; %&gt;&lt;/th&gt;
        &lt;th&gt;&lt;%= link_to &#039;First name&#039;, :sort =&gt; &quot;profiles.first_name&quot; %&gt;&lt;/th&gt;
        &lt;th&gt;&lt;%= link_to &#039;Email&#039;, :sort =&gt; &quot;email&quot; %&gt;&lt;/th&gt;
        &lt;th&gt;&lt;%= link_to &#039;Country&#039;, :sort =&gt; &quot;profiles.country&quot; %&gt;&lt;/th&gt;
        &lt;th&gt;active&lt;/th&gt;
        &lt;th&gt;blocked&lt;/th&gt;
        &lt;th&gt;created_at&lt;/th&gt;
        &lt;th&gt;created_by&lt;/th&gt;
      &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
      &lt;% @users.each do |user| %&gt;
          &lt;tr&gt;
            &lt;td&gt;&lt;%= user.id %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= user.profile.last_name %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= user.profile.first_name %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= user.email %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= user.profile.country %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= user.active %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= user.blocked %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= user.created_at.strftime(&quot;%d %B %Y&quot;) %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= user.created_by %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= link_to &#039;Show&#039;, backstage_user_profile_path(user, user.profile) %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= link_to &#039;Edit&#039;, edit_backstage_user_profile_path(user, user.profile) %&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%= link_to &#039;Destroy&#039;, backstage_user_path(user), confirm: &#039;Are you sure?&#039;, method: :delete %&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;% end %&gt;
      &lt;/tbody&gt;
      &lt;tfoot&gt;&lt;/tfoot&gt;
    &lt;/table&gt;
    &lt;aside id=&quot;switch-view-wrapper&quot; class=&quot;btn-group btn-group-vertical span2&quot; data-toggle=&quot;buttons-radio&quot;&gt;
      &lt;%= link_to &#039;All&#039;, backstage_users_path, :class =&gt; &#039;btn&#039; %&gt;
      &lt;%= link_to &#039;Active&#039;, backstage_active_users_path, :class =&gt; &#039;btn&#039; %&gt;
      &lt;%= link_to &#039;Inactive&#039;, backstage_active_users_path, :class =&gt; &#039;btn&#039; %&gt;
      &lt;%= link_to &#039;Blocked&#039;, backstage_active_users_path, :class =&gt; &#039;btn&#039; %&gt;
      &lt;%= link_to &#039;Not Blocked&#039;, backstage_active_users_path, :class =&gt; &#039;btn&#039; %&gt;
    &lt;/aside&gt;
  &lt;/div&gt;

  &lt;div id=&quot;grid-bottom-pagination&quot;&gt;
    &lt;%= will_paginate %&gt;
  &lt;/div&gt;
&lt;/div&gt;</code></pre></div><p>I probably missing or misunderstood something but cannot find a way to solve that... <br />I need some help and explanations here. <br />Thanks in advance </p><p>Cheers</p>]]></description>
			<author><![CDATA[dummy@example.com (anso)]]></author>
			<pubDate>Mon, 04 Mar 2013 18:11:47 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=160856#p160856</guid>
		</item>
	</channel>
</rss>
