logo
down
shadow

One action in Rails controller sends no data back


One action in Rails controller sends no data back

By : Terry Leeper
Date : November 22 2020, 10:38 AM
I wish this help you Looks like you're bumping into the default response for action_controller / responder.rb
code :
# File actionpack/lib/action_controller/metal/responder.rb, line 203
def api_behavior(error)
  raise error unless resourceful?
  raise MissingRenderer.new(format) unless has_renderer?

  if get?
    display resource
  elsif post?
    display resource, :status => :created, :location => api_location
  else
    head :no_content
  end
end


Share : facebook icon twitter icon
Add default, fall-back action for controller in rails

Add default, fall-back action for controller in rails


By : lisp lisp
Date : March 29 2020, 07:55 AM
To fix this issue I have a controller with a single index action. The same resource has some static assets which don't require anything in the controller. There used to be some others which are now gone but there are lingering links here and there on the web.
code :
class MyConstraint
  BYPASSED_ROUTES = ['anything']

  def matches?(request)
    BYPASSED_ROUTES.map {|r| request.path.include?(r)}.empty?
  end
end

MyApp::Application.routes.draw do
  # Insert other routes before the catch-all one
  match "/resource/*path" => "resource#index", :constraints => MyConstraint.new
end
How to redirect from one action of controller A to an action of controller B and back in Rails?

How to redirect from one action of controller A to an action of controller B and back in Rails?


By : jc50
Date : March 29 2020, 07:55 AM
This might help you One option I see is to save employee data in session (session[:temp_employee] = params[:employee]), then redirect to creating the company. In the company controller, after the company is saved you could check if employee is present in the session then redirect client back to create action of the employees controller.
This would additionally require you to:
Unable to send back data to action in MVC controller from javascript

Unable to send back data to action in MVC controller from javascript


By : Cairis
Date : March 29 2020, 07:55 AM
it should still fix some issue I use jquery to load rows into a table. Each row contains an Id.
code :
Used ajax to send data(id) to the action, but the action ended up returning the html of     
the new view as the response instead of redirecting
function myfunction()
{
  var formId = $(evt.currentTarget).data("formId");

  // window.location = "ActionNameHere?formId" + formId;
 // foryour Case
 window.location="Test?formId="+formId;

}
public ActionResult Test(string formId)
{            
    ViewBag.Title = "Testing Page ";
    ViewBag.Message = "Testing Page" + formId + "hi";            
    return View();
}
  document.loacation.href.replace('URL')
in ember, how do I unit test controller action that sends another action?

in ember, how do I unit test controller action that sends another action?


By : Chien Nguyen
Date : March 29 2020, 07:55 AM
I wish this helpful for you Specify target of your subject (controller) and let your target have actionName declared in actions object:
code :
import { moduleFor, test } from 'ember-qunit';

moduleFor('controller:my-controller');

test('it fires an action', function(assert) {
  let controller = this.subject();

  controller.set('target', Ember.Controller.extend({
    actions: {
        actionName: () => assert.ok(true, 'Action bubbled!')
    }
  }).create());

  controller.send('doSomething');
});
How to make ajax call that sends data to rails controller and returns data?

How to make ajax call that sends data to rails controller and returns data?


By : abardin85
Date : March 29 2020, 07:55 AM
it fixes the issue I'm making a Rails app that uses Leaflet. I have some pipes on my map and I want this functionality: when I click on the map, I get, as a response, how many pipes are within the distance of 50 miles. Now, in order to get this information, I need ST_Distance method from postgis, used on Pipe class (in the pipes_controller). Leaflet can get me the coordinates of the click, I need to send these to the controller, get it to calculate the number of pipes within 50 miles and return that number so it can be shown through javascript. I don't know how to get ajax to do this in one request, as a post/get method. , This worked:
pipes_controller.rb
Related Posts Related Posts :
  • 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
  • RailsInstaller: Can I maintain the gem fold when re-installing a new version?
  • couldn't find file 'jquery-ui' i get this error even after having this file in my application.js
  • Ruby regex to split user and date text input
  • Tool like BetterErrors for JRuby?
  • redirect_to in action destroy ruby on rails
  • Where are the I18n.t link and reference paths?
  • Sending emails to multiple recipients in rails app
  • Rails, Devise, Sign up = write name in other Database
  • pass custom attribute on rspec factory_girl controller test
  • rails generate uses wrong version of Ruby
  • Duplicate Requests from a Browser
  • Local data (JSON) in Middleman inside a different path than /data
  • How to pass numbers in an array into a SQL statement
  • ActiveAdmin - Allow non-logged-in users to view but not edit resources
  • How to refactor this Model logic in Rails
  • :readonly key of belongs_to method doesn't work
  • Create a new view in directory
  • nested resources in devise
  • Yaml value with a leading `!`
  • Rails admin show username instead of User #5
  • Can't start WEBrick with Byebug on
  • Failing Rspec test of a FactoryGirl object
  • engine yard No application found matching remotes:
  • Rails 4 sessions cookie is not set
  • How do I flush a class method in Rails 4 using memcached?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org