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 546521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:52:32+00:00 2026-05-13T10:52:32+00:00

I have a name route: map.up_vote ‘up_vote’, :controller => ‘rep’, :action => ‘up_vote But

  • 0

I have a name route:

map.up_vote 'up_vote', :controller => 'rep', :action => 'up_vote

But up_vote requires two arguments to be passed in, postID and posterID and I can’t seem to figure how to do that in a partial, but in an integration test I have no issues.

Partial:

link_to 'Up Vote', up_vote_path, {:postID => session[:user_post_id], :postersID => session[:poster_id]} 

Integration test:

post up_vote_path,{:postID => @latest.id,:postersID => users(:bob).id} (this works ok)

1) What is going on the in the partial?

2) What changes can I make to my tests to catch this?

  • 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-13T10:52:32+00:00Added an answer on May 13, 2026 at 10:52 am

    A question: why are you passing your session variables in a link? You can get them directly from the session…

    I don’t know if there are any special reasons to put :user_post_id and :poster_id in the session but I recommend you two things:

    1) Pass your variables in urls, sessions can be evil (try hitting back, refresh and forward on your browser)

    2) Use resources in your URLs / controller actions logic.

    Example (valid only if I got it right and you’re voting an user’s post):

    routes:

    map.resources :users do |user|
      user.resources :posts do |post|
        post.resource :vote
      end
    end
    

    So you can have this url:

    /users/:id/posts/:post_id/vote
    

    And the link path:

    link_to "Up", user_post_vote_path(@user, @post), :method => :create
    

    I putting @user and @post instead of the integers because path methods accept them and you can build a shorter version with:

    link_to "Up", [@user, @post, :vote] # or [:vote, @post, @user]
    

    Implementing:

    class VoteController ....
      def create
        # do your stuff here
      end
    end
    

    This way it will be easier and RESTful.

    Ryan Bates got a great episode on resources, it definately worths a look.

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

Sidebar

Related Questions

I have these two routes: routes.MapRoute( Default, // Route name {controller}/{action}/{id}, // URL with
I have the following route defined routes.MapRoute( ItemName, {controller}/{action}/{projectName}/{name}, new { controller = Home,
I have a controller action that has the same name as a file path.
ASP.NET MVC routes have names when mapped: routes.MapRoute( Debug, // Route name -- how
So I have added this route to my map: routes.MapRoute( Default, /Bikes/{id}, new {
HI I have the following routing table routes.MapRoute(null, Save, // Route name new {
I am trying to get the controller and action name based on a path.
I have m2m field, lets say it have name 'relations', so i want to
I have the name of a function in JavaScript as a string. How do
I have a name of table or view in PostgreSQL database and need to

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.