I have an action create and another action register_and_create. The first creates subscription and the seconds creates user and subscription. But I will have to copy the code of create action in register_and_create action. So is it good practice to use Net::HTTP to send POST request from register_and_create to create action?
Should I use Net::HTTP when I want to make POST request to an action
71 Views Asked by Tsvetelina Borisova At
1
There are 1 best solutions below
Related Questions in RUBY
- how to integrate cashfree payment gateway in ruby on rails project
- RSpec Capybara throwing Selenium error when trying to click a button with browser confirm
- Duplicate GET requests - Rails & Heroku
- convert csv file with json data inside to a column, rows table in 2nd csv file
- Installing dependencies from a gemspec file
- Verifying Google Identity OAuth2 token with Ruby
- Java code of AES/GCM/NoPadding encryption algorithm with authentication tag
- How to fix error in model with gem lockbox
- Cannot install Ruby Gem on Window
- use logstash filter ,aes gcm encrypted in ruby,but cannot decrypted in java
- In Rails 7, what is the right ActiveRecord callback to use if I need to prevent (or rollback) persistance on error?
- How can I go through an array and still remove elements from it
- Nokogiri only returning 5 results
- How do I get the fullscreen mode in firefox?
- undefined group option when using branch reset group regex in Ruby
Related Questions in RUBY-ON-RAILS-3
- is there a way to write this clean?
- HTML to pdf conversion using wickedpdf with page count
- Rails rspec feature itegration testing for basic auhentication
- ImageKit works fine on local but doesn't work on heroku why?
- SSL Configuration Issue: Website Redirects Too Many Times and CSRF Token Mismatch
- How to fix permission error while install bundle for rails project on ubuntu?
- Active Admin filters not displaying on screen but present in the html DOM
- Why is the page title not not changing in a turbo-ios app
- Resolving 'net::ERR_BLOCKED_BY_CLIENT' Error After Upgrading Ruby to 3.2.2 and Rails to 7 with jsbundling Gem
- Cant install Mysql2 Gem::Ext::BuildError: ERROR: Failed to build gem native extension
- Filtering Users with Associated Records by Specific Date in Rails
- How to handle the params for accepts_nested_attributes_for for has_many association containing a lot of fields on both associated table
- Issue when Rounding Decimal values
- Map an activerecord array to avoid that two item with the same attribute are in a sequential position
- Devise Registration Ruby on Rails - Migration Error: Duplicate column name
Related Questions in RUBY-1.9.2
- How do I get Ruby's String Split Method to Include Newlines in the Output?
- How to set SameSite attribute to 'None; Secure' in Rails3.1.12 and Ruby1.9.3
- Error: "incompatible character encodings: ASCII-8BIT and UTF-8" & "invalid byte sequence in UTF-8" when create a record RoR into SQL Server 2008 R2
- How to parse a JSON file in Ruby version 1.8.7
- unicode_utils gem won't install
- Run python from a click event in ruby
- Optional argument in `File.read` with Ruby 1.9.2
- invalid byte sequence in UTF-8 - Rails 3.2
- ActiveRecord::RecordNotSaved - Rails 3 seeding data
- quote_char causing fits in ruby CSV import
- DBI::InterfaceError: Could not load driver (uninitialized constant MysqlError)
- Should I use Net::HTTP when I want to make POST request to an action
- rails webrick httpserver encoding issue
- undefined method `selector' for #<ActiveRecord::Relation:0xbb8710c> when using mongoid to save a record
- Getting error installing ruby 1.9.2-p320 using RVM
Related Questions in NET-HTTP
- Ruby Net::Http split write and read operation for non-blocking
- "End of file reached" error OR Zlib::BufError using HTTParty
- Is there a way to send JSON with DELETE request with Net::HTTP?
- Reuse same TCP connection in Golang using gorequest
- How to add headers info using Transport in golang net/http
- rails to_json remove quote
- Golang net-http spawn multiple tcp session
- Ruby : Net::HTTP parse adds %0A at end
- What is the "accept" part for?
- How do I set TCPSocket attributes for only a method and not globally?
- If Net::HTTP's open_timeout and read_timeout are not set, will it wait indefinitely?
- Errno::ECONNRESET (Connection reset by peer - SSL_connect) OpenSSL certificates? Ruby on Rails 2.3.15
- What is Net::HTTP doing differently than executing curl in ruby?
- How to download an image file via HTTP into a temp file?
- Using Net::HTTP, how can you store the url that you queried?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
No, it is not a good practice.
If it was GET method, you should execute action code and return redirection to the second action.
For POST methods you should execute all code in
register_and_createaction. SendingNET:HTTPmight cause a lot of problems - you have to make sure you assigned all HTTP headers, unnecessary requests comes to the server, etc.If you found common parts of codes it might be good to move your code to
libmodule and useincludein your controllers.For example: