Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6092379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:26:08+00:00 2026-05-23T12:26:08+00:00

Hi I’m trying to implement jquery token input according to railscasts #258 http://railscasts.com/episodes/258-token-fields Where

  • 0

Hi I’m trying to implement jquery token input according to railscasts #258 http://railscasts.com/episodes/258-token-fields

Where the railscasts uses ‘author’ I am using ‘artist’

When I start typing in the artist_token field my json search request is processed by the UsersController#show action instead of the ArtistsController#index action.

Since my _post_form partial is rendered on the PagesController#home view I would have thought the json might be processed by PagesController#home but for some reason it UsersController#show

Any ideas what I’m doing wrong?

## working example from railscasts #258

Started GET "/authors.json?q=d" for 127.0.0.1 at 2011-07-03 16:27:31 -0700
  Processing by AuthorsController#index as JSON
  Parameters: {"q"=>"d"}
  Author Load (0.7ms)  SELECT "authors".* FROM "authors" WHERE (name like '%d%')
Completed 200 OK in 17ms (Views: 2.3ms | ActiveRecord: 0.7ms)


## my log with UsersController#show instead of ArtistsController#index ???

Started GET "/artists.json?q=d" for 127.0.0.1 at 2011-07-03 16:12:44 -0700
  Processing by UsersController#show as JSON
  Parameters: {"q"=>"d", "id"=>"artists.json"}
  User Load (0.3ms)  SELECT "users".* FROM "users" WHERE "users"."cached_slug" = 'artists.json' LIMIT 1
  SQL (0.1ms)  SELECT sluggable_id FROM slugs WHERE ((slugs.sluggable_type = 'User' AND slugs.name = 'artists.json' AND slugs.sequence = 1))
  User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 0 LIMIT 1
Redirected to http://localhost:3000/
Completed 302 Found in 133ms

## pages controller

class PagesController < ApplicationController

  def home
    @title = "Home"
    @featured_posts = Post.featured.limit(10)
    if user_signed_in?
      @user = current_user
      @post = current_user.posts.build
      @feed_items = current_user.feed.paginate(:per_page => "10", :page => params[:page])
    else
     #render :layout => 'special_layout' 
    end
  end

## views/pages/home.html.erb 

<% if user_signed_in? %>

   <%= render 'shared/post_form'%>

   <%= render 'shared/user_info' %>
   <%= render 'shared/stats' %>

## views/shared/_post form.html.erb

<%= form_for @post, :validate => true, :html => {:multipart => true} do |f| %>
  <%= render 'shared/error_messages', :object => f.object %>
    <div class="field">
    <%= f.label :title, 'Title:' %><br /> 
        <%= f.text_field :title %><br />

     <%= f.label :artist_tokens, "Artists" %><br />
     <%= f.text_field :artist_tokens, "data-pre" => @post.artists.map(&:attributes).to_json %>
    <div>
    <div class="actions">
      <%= f.submit "Submit" %>
    </div>
<% end %>


## artists controller

class ArtistsController < ApplicationController
  def index
    @artists = Artist.where("name like ?", "%#{params[:q]}%")
    respond_to do |format|
      format.html
      format.json { render :json => @artists.map(&:attributes) }
    end
  end

  def show
    @artist = Artist.find(params[:id])
  end

  def new
    @artist = Artist.new
  end

  def create
    @artist = Artist.new(params[:author])
    if @artist.save
      redirect_to @artist, :notice => "Successfully created artist."
    else
      render :action => 'new'
    end
  end

  def edit
    @artist = Artist.find(params[:id])
  end

  def update
    @artist = Artist.find(params[:id])
    if @artist.update_attributes(params[:artist])
      redirect_to @artist, :notice  => "Successfully updated artist."
    else
      render :action => 'edit'
    end
  end

  def destroy
    @artist = Artist.find(params[:id])
    @artist.destroy
    redirect_to authors_url, :notice => "Successfully destroyed artist."
  end
end


## artist model

class Artist < ActiveRecord::Base
attr_accessible :name
has_many :artistizations
has_many :posts, :through => :artistizations

end

## artistization model

class Artistization < ActiveRecord::Base
attr_accessible :post_id, :artist_id
belongs_to :artist
belongs_to :post

end

## post model

  attr_accessible :title, :artist_tokens

  has_many :artistizations
  has_many :artists, :through => :artistizations 
  attr_reader :artist_tokens

  def artist_tokens=(ids)
    self.artist_ids = ids.split(",")
  end


## application.js

$(function() {
  $("#post_artist_tokens").tokenInput("/artists.json", {
    crossDomain: false,
    prePopulate: $("#post_artist_tokens").data("pre"),
    theme: "facebook"

  });
});

 ## routes 


  match 'auth/:provider/callback' => 'authentications#create'
  resources :authentications

  devise_for :admins
  match '/admin' => 'RailsAdmin/Main#index'

  devise_for :users, :controllers => {:registrations => 'registrations'}

  resources :posts do
      member do
      get :likers
      end
      collection do
        get :search
      end
  end  

  resources :relationships, :only => [:create, :destroy]
  resources :appreciations, :only => [:create, :destroy]


  match '/contact', :to => 'pages#contact'
  match '/about',   :to => 'pages#about'
  match '/help',    :to => 'pages#help'
  match '/blog',    :to => 'pages#blog'


  resources :users do
     member do
     get :following, :followers, :likes
     end
     resources :collections
 end

  # 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)))'
    match '/:id' => 'users#show', :constraints => {:id => /[^\/]+/}, :as => :global_user
    root :to => "pages#home"
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:26:09+00:00Added an answer on May 23, 2026 at 12:26 pm

    Usually when you have problems like these, where something is being processed by a ‘wrong’ controller, you should first check your routes.rb file.

    Right away I noticed this:

    # 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)))'
    match '/:id' => 'users#show', :constraints => {:id => /[^\/]+/}, :as => :global_user
    

    Basically it seems like every request in that format is being routed to the users#show action. Try commenting out that match directive and see if it works now. If other things break then it’s up to you to see why you need that there and how you can accommodate accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.