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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:55:07+00:00 2026-06-06T10:55:07+00:00

I am working on a very simple project to learn Rails better, coming from

  • 0

I am working on a very simple project to learn Rails better, coming from a C# background. It seems to be rendering the incorrect form action with my code.

It currently has 2 models which are using the routes of

  resources :leaks
  resources :passwords

This is to give me the basic routes:

Matts-MacBook-Pro:pwcrack-webgui mandreko$ rvm 1.9.3 do rake routes
        leaks GET    /leaks(.:format)              leaks#index
              POST   /leaks(.:format)              leaks#create
     new_leak GET    /leaks/new(.:format)          leaks#new
    edit_leak GET    /leaks/:id/edit(.:format)     leaks#edit
         leak GET    /leaks/:id(.:format)          leaks#show
              PUT    /leaks/:id(.:format)          leaks#update
              DELETE /leaks/:id(.:format)          leaks#destroy
    passwords GET    /passwords(.:format)          passwords#index
              POST   /passwords(.:format)          passwords#create
 new_password GET    /passwords/new(.:format)      passwords#new
edit_password GET    /passwords/:id/edit(.:format) passwords#edit
     password GET    /passwords/:id(.:format)      passwords#show
              PUT    /passwords/:id(.:format)      passwords#update
              DELETE /passwords/:id(.:format)      passwords#destroy

In my leakscontroller.rb, I have 2 methods, to try create a new leak:

def new
  @leak = Leak.new

  respond_to do |format|
    format.html # new.html.erb
    format.xml { render :xml => @leak }
  end
end

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

And lastly, in my new.html.erb, I have:

<%= form_for @leak, :url => { :action => "create" } do |f| %>
    <div class="field>
        <%= f.label :source %>
        <%= f.text_field :source %>
    </div>
    <div class="field">
        <%= f.label :file %>
        <%= f.file_field :file %>
    </div>
    <div>
        <%= f.submit %>
    </div>
<% end %>

I would think that with this view, it would create a form with action=Create, but the following code is generated:

<form accept-charset="UTF-8" action="/leaks" class="new_leak" enctype="multipart/form-data" id="new_leak" method="post">

Any clue why this would be the case?

  • 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-06T10:55:09+00:00Added an answer on June 6, 2026 at 10:55 am

    Because of Rails’ restful nature and some serious metaprogramming, the form_for helper when using with an instance of ActiveRecord object, assumes that a simple:

    <% form_for @leak do |f| %>
    

    When submitted would make a POST to the create action on your controller.
    If you need a more specific form, that do not goes according to the default patterns a Rails App follows, you can use a form_tag helper.
    For example if you have a secret_action in your controller, you create a route in your routes.rb.

    resources :leaks do
      collection do
        post :secret_action
      end
    end
    

    And a form like this:

    <% form_tag secret_action_leaks_path do %>
    

    And you get the behavior you expect. Once you understand the basic of routing, paths, forms in Rails, you would do these things without even thinking.
    Try reading some of this: http://guides.rubyonrails.org/routing.html

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

Sidebar

Related Questions

I'm working on a WPF project and have implemented a very simple way to
I have a very simple Django project working on my Windows machine. When I
I am working on a project where we offer a very simple homespun CMS
I'm working on a very simple blog engine in Java in order to learn
Im working on a very simple project in java that utilizes the Swing component
I'm working on a very simple first step of a project I'm doing: a
I am working on a personal project very simple but this is part of
I'm working on a very simple iPhone app, that in the end will have
I'm working on converting a very simple java desktop application to run in java
I've got a very simple DotNetOpenAuth implementation working for my MVC4 site (Google only).

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.