Tag: ajax

How do I access a rails variable that is only accessible to a partial?

Sorry I’m a newbie to Ruby on Rails. I’m very confused about the big picture, so your help would be appreciated. In my application.html.haml, I call =yield, which takes its output from ranked.html.haml. Now, the latter has access to the rails variable @featured_image. What I want to do is to get hold of this rails […]

Database values are not coming in same page without reloading in Rails 3

I want after searching by receipt number the values should display in same page without reloading the page using Rails3. But I am getting all values but not in the same page. Can anybody please help me to resolve this issue? I am explaining my code below. views/homes/home.html.erb <% if current_admin %> <div id=”page-container” class=”full-width”> […]

how to pass data in json format to do an ajax post call in ruby?

First of all, I am calling a javascript ajax function that will call to the ruby function that gets called when I go to the URL: /cnet From there, I want to do another post call from ruby in which I want to pass json data. How do I pass json formatted data to do […]

How to call 3 new checkboxes upon checking 3 old checkboxes?

Then if those new boxes are checked another 3 checkboxes would show for that level. habits/_form.html.erb <label id=”<%= @habit.id %>” class=”habit-id”> Missed: </label> <% @habit.levels.each_with_index do |level, index| %> <% if @habit.current_level >= (index + 1) %> <p> <label id=”<%= level.id %>” class=”level-id”> Level <%= index + 1 %>: </label> <%= check_box_tag nil, true, level.missed_days […]

Why is this button_to rendering incorrectly in Rails 3.2.11?

I am working in Rails 3.2.11 and I cannot figure out why this button will not render per the API documentation. Specifically, I cannot get the data-remote attribute to render correctly. Is there a bug in my code? Right now this code: <%= button_to “Test”, :action => “test”, :remote => true, :form_class => “test_button” %> […]

can mechanize read ajax? (ruby)

can I get the correct data/text that is displayed via AJAX using mechanize in ruby? Or is there any other scripting gem that would allow me to do so?

How would I go about recording changes in a large text field?

Let’s say I want a user to write a story in 20 minutes. After the user is done I want to play back the story writing process so I can see how the user went about doing it. How would I do this? I don’t want to watch every second of it, obviously, but I’d […]

Is it considered good practice to return a code different than 200 from my controllers, in order to trigger an ajax error?

I have code like the following ( it’s a remote form ) def something @user = User.find_by_email(params[:email]) @success = true @error = nil if !@user @success = false @error = “No such user” elsif !@user.some_condition @success = false @error = “User did not pass condition” end respond_to do |format| format.json { render “my_json_view”,:status => @success […]

How do I pass params to Rails controller method then return value using JQuery/AJAX?

I am using a click function to first get the array/position, then post it via an AJAX call to a controller method. I would then like the method to return a boolean value to enable the addClass in the jquery function. The console is consistently throwing a 500 server error. Here is the .js file: […]

Passing Javascript variables to Rails partials

I am new in Rails and I am struggling on an apparently easy task. I have a (stripped down) form: <%= form_for @order, html: { :class => ‘form-inline’ } do |f| %> <fieldset> <legend><%= params[:action].capitalize %> Order</legend> <table class=”table”> <thead> <tr> <th><%= f.label :symbol %></th> <th><%= f.label :price %></th> </tr> </thead> <tbody> <tr> <td><%= f.text_field […]

Ruby is the best programming language in the world - Ruby on Rails.