logo
down
shadow

Rails - How to invoke methods upon submission of form_tag?


Rails - How to invoke methods upon submission of form_tag?

By : Justin McLeod
Date : November 17 2020, 11:58 AM
it helps some times submit_tag calls the action specified by the form_for, if no action is specified then it will default to the current action, which in this case is 'redemption' as Doon states below. So using :action => 'your action' would probably be more clear. More info here.
code :


Share : facebook icon twitter icon
Rails 3.0 : form_tag How to convert this form_for to form_tag.

Rails 3.0 : form_tag How to convert this form_for to form_tag.


By : Jan Vlach
Date : March 29 2020, 07:55 AM
this one helps. This is the login page for my app but the role selected for a user is not being reflected in the database so i want to try changing form_for into form_tag to see if the data gets submitted.
code :
<%= form_tag users_path, methods=> post:do %>
  <% if @user.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
      <ul>
        <% @user.errors.full_messages.each do |msg| %>
          <li><%= msg %></li>
        <% end %>
      </ul>
    </div>
  <% end %>
  <div class="field">
    <%= label_tag 'email' %><br />
    <%= text_field_tag :email, params[:email], :placeholder => "Email" %>
  </div>
  <div class="field">
    <%= label_tag 'username' %><br />
    <%= text_field_tag :username, params[:username], :placeholder => "Username" %>
  </div>
  <% if @current_method == "new" %>
    <div class="field">
      <%= label_tag :password %><br />
      <%= password_field_tag 'password' %>
    </div>
    <div class="field">
      <%= label_tag :password_confirmation %><br />
      <%= f.password_field_tag 'password_confirmation' %>
    </div>
  <% end %>
  <% for role in Role.find(:all) %>
    <div>
      <%= check_box_tag "user[role_ids][]", role.id, @user.roles.include?(role) %>
      <%= role.name %>
    </div>
  <% end %>
  <div class="actions">
 <%= submit_tag 'submit' %>
  </div>
<% end %>
RoR: form_tag, redirect after submission

RoR: form_tag, redirect after submission


By : Noman Ahmad
Date : March 29 2020, 07:55 AM
I wish did fix the issue. The problem:
The post request on http://myserver.com.ua/ goes to / and that is good
Call 2 post controller methods on single form submission in rails

Call 2 post controller methods on single form submission in rails


By : user3524199
Date : March 29 2020, 07:55 AM
I hope this helps . You wouldn't go to the notifications create action, you would just do it in the Invitation create. The below code will use a shared concern method, explained below it:
code :
class InvitationsController < ApplicationController
    include Notifications

    #....

    def create
        invitation = Invitiation.create(invitation_params)
        create_notification(invitation)
    end

    private

    def invitation_params
        # strong params code
    end
end
class RsvpsController < ApplicationController
    include Notifications

    #....

    def create
        rsvp = Rsvp.create(rsvp_params)
        create_notification(rsvp)
    end

    private

    def rsvp_params
        # strong params code
    end
end
module Notifications
  extend ActiveSupport::Concern

  def create_notification(object)
    Notification.create(object_id: object.id, object_type: object_type)
  end
end
How clojure invoke methods in clj file by function invoke defined in interface IFn?

How clojure invoke methods in clj file by function invoke defined in interface IFn?


By : Jbao
Date : March 29 2020, 07:55 AM
hop of those help? It's not very clear what you're trying to achieve. Are you trying to compile Clojure itself from scratch? Are you trying to understand how the Clojure compiler works?
It also seems you are not starting from the right class. The class in clojure.main is the Clojure REPL itself, not the compiler. In fact, you can launch it from Java:
code :
$ java -cp /home/denis/.m2/repository/org/clojure/clojure/1.10.0/clojure-1.10.0.jar:/home/denis/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar clojure.main
Clojure 1.10.0
user=> (+ 1 2)
3
form_tag inside a form_tag - In rails

form_tag inside a form_tag - In rails


By : Mohamed Ahmed
Date : March 29 2020, 07:55 AM
this will help HTML does not allow nested forms, thus it's reasonable that the helpers are not designed to support nesting.
Related Posts Related Posts :
  • Ruby on Rails - unable to convert "\x89" from ASCII-8BIT to UTF-8 for xxx/xxxx/xxxx
  • In Ruby on Rails, After send_file method delete the file from server
  • An error occurred while installing nokogiri (1.6.6.2), and Bundler cannot continue
  • How to setup nested routing for a self referencing controller in Rails 4
  • middleman app it is possible to create a contact form?
  • How to refactor this piece of code
  • How can I know if a user has access to all or just some resources with Cancan?
  • How can I run a ruby class from rake file?
  • Send JSON data as post method from rails controller to a web service
  • How to test Controllers under different namespaces and why this test fails?
  • rspec expect condition OR condition
  • Page loads unnecessary queries Ruby On Rails
  • Why "bundle install" try to install outdated version of gems?
  • Rails - Customize model validation error messages but without a database
  • When to switch from cucumber to rspec in the BDD cycle for a login procedure
  • Multipart response for web service
  • How to hide Add new option in Rails Admin
  • Override CollectionProxy find method
  • Rails 4 simple_form has_many through check boxes not saving
  • ruby on rails authentication using devise gem
  • Rails iteration over arrays and hashes
  • Creating inline date_select dropdowns using simple_form and zurb foundation
  • NameError in SongsController#index uninitialized constant Song::FriendlyId
  • Rails how to improve if record exists?
  • omniauth custom request phase form
  • Rails 5 - Saving the absolute current url via a button to a cookie?
  • How can / should I override the `build` method for a my model?
  • Install Rails Failed on OSX 10.8.4
  • ruby on rails - undefined method valid?
  • Users Registration on POST
  • Rails application variables in carrierwave store_dir
  • How to customize simple_form for json nested hash
  • Couldn't find file 'jquery', Sprockets::FileNotFound in StaticPages#home error
  • How should I use the alias_method_chain for the build method?
  • how to create two custom registration forms in devise?
  • Rails 4 link_to Destroy not working in Getting Started tutorial
  • How does ruby on rails dynamically define `find_by_id`, `find_by_name` methods?
  • JBuilder dynamic keys for model attributes
  • `initialize': No such file or directory - getaddrinfo (Errno::ENOENT) when Rails new app
  • What is the Ruby equivalent of Node.js' socket.io?
  • Where rails store standard helpers?
  • how to check expected result matches any of give values in rspec?
  • Form submission to create multiple objects
  • Simple Twitter Login with Rails and Email confirmation
  • Where should helpful functions for my controller go in Rails?
  • Using session variable in the Model or the other way
  • Why can't I have ruby code and comments in Embedded Ruby?
  • Rails: How can I make an object available in all views?
  • Cannot enter simply form information into SQLite DB (Rails)
  • Rails - Retain form values on failed submission. Getting "First argument in form cannot contain nil or be empty&quo
  • How to handle STI and build related models automatically?
  • Suppress an error when saving a record in Rails
  • Rails AJAX reload the page. Why?
  • How to pass user attributes to action mailer
  • Custom Validator to Prevent an appointment from being scheduled too early in day?
  • Postgres Enable TCP/IP Connection
  • How do I avoid the circular argument reference warning in activesupport
  • Unable to push to heroku master because of rails/spring version error
  • deep nested routes in rails
  • Best approach to Users Profile Images in Rails App
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org