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

  • Home
  • SEARCH
  • 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 8269311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:11:06+00:00 2026-06-08T06:11:06+00:00

Statement Imagine we have an inventory app, there it is a Movement model, it

  • 0

Statement

Imagine we have an inventory app, there it is a Movement model, it represent any movement like products purchase or products sale. So we have default REST routes.

    movements GET    /movements(.:format)          {:action=>"index", :controller=>"movements"}
              POST   /movements(.:format)          {:action=>"create", :controller=>"movements"}
 new_movement GET    /movements/new(.:format)      {:action=>"new", :controller=>"movements"}
edit_movement GET    /movements/:id/edit(.:format) {:action=>"edit", :controller=>"movements"}
     movement GET    /movements/:id(.:format)      {:action=>"show", :controller=>"movements"}
              PUT    /movements/:id(.:format)      {:action=>"update", :controller=>"movements"}
              DELETE /movements/:id(.:format)      {:action=>"destroy", :controller=>"movements"}

For mnemonic proposes, we want to have some descriptive routes, like:

 new_purchase        /purchase/new(.:format)       {:controller=>"movements", :action=>"new_purchase"}
edit_purchase        /purchase/:id/edit(.:format)  {:controller=>"movements", :action=>"edit_purchase"}

If you can see purchase‘s are same model likemovement‘s, actually are processed by MovementsController, but there with have different flow and treatment, this specified by create_purchase instead of create.

Questions

  1. How should I add restful routes for purchase‘s? Taking care of specify HTTP methods like GET, POST, PUT, DELETE, etc.

  2. How should I write form_for tags? Using movement model we can write: <%= form_for(@movement) do |f| %> but how is to call purchase paths for create or update methods?

  3. How should I specify validation rules for purchase‘s? I have specified some rules on Movement model, but they are not applied for purchase‘s when a form is submitted.

  • 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-06-08T06:11:07+00:00Added an answer on June 8, 2026 at 6:11 am

    You could use some thing like this in your routes file

     match '/purchase/new(.:format)' => 'movements#new_purchase'     :via => :get
     match '/purchase/:id/edit(.:format)' => 'movements#edit_purchase' :via => :post 
    

    and you can mention others like delete, put in :via

    for more info look at this link
    If you want to change create to create_purchases go to the movements controller and change the definition names.

    for the second question you could do something like this

    form_tag(:controller => "controller_name", :action => "action_name", :method => "get")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine I have the following SELECT statement in a view (SQL Server 2008): SELECT
For example, imagine I have an object defined like so: public class Example {
Imagine I have something like this: def example = { def temp = ConferenceUser.findAllByUser(User.get(session.user))
I have a slide out nav bar that I would like open by default
I have a large statement: SELECT a.user_id, a.user_name, s.name, s.value, d.default FROM accounts a,
Problem statement We have one employer that wants to interview N people, and therefore
SQL statement: INSERT INTO order (`ORDER_ID`,`SALE_CODE`,`CREATED_AT`,`UPDATED_AT`) VALUES ('2646253286','HPHS20','2009-07-11 12:07:40','2009-07-11 12:07:40') Error: You have an
I'd like to have the compiler warn me if I'm not handling every if
Say I have a block like this: <% @help_sections.each do |section| %> <li><%= section.name
imagine the following problem in grails you have some kind of audit trail domain

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.