AJAX not working in Rails same-page update
up vote
-1
down vote
favorite
I am trying to build a Q&A app with Ajax on the Index.html.erb. I manage to get the form remotely loading, but when saving the records, the AJAX does not work and the user is taken to the normal show.html.erb. Apart from the Ajax not kicking off, everything works well.
My code is as below:
index.html.erb (Contain a partial for input, and a partial for results)
<div>
<h3 class="section_title"> Q&A </h3>
<hr>
<div id="qanda-form" style="display:none;"> </div>
</div>
<div id="qandas">
<%= render 'qandas/qanda' %>
</div>
_qanda.html.erb (is the partial for results)
<% @qandas.each do |my_qanda| %>
<div class="col-md-9">
<div>
Created <%= local_time(my_qanda.created_at) %>, by <%= User.find_by(id: my_qanda.user_id).full_name %>
</div>
</div>
<% end %>
_form.html.erb (is the input form - has nested form via Cocoon)
<%= simple_form_for @qanda, remote: true do |f| %>
<%= f.error_notification %>
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
<div class="col-md-12 form-inputs">
<div class="col-md-8">
<%= f.input :title, label: 'Q&A Title:' %>
</div>
</div>
<div class="qandasquestions">
<%= f.simple_fields_for :qandasquestions do |builder| %>
<% render 'qandas/qandasquestion_fields', f: builder %>
<% end %>
<div class="links btn-group" style="min-height: 34px !important">
<%= f.button :submit, "Publish Q&A", class: "btn btn-default" %>
<%= link_to_add_association 'Add Question', f, :qandasquestions, class: 'btn btn-default', data: {association_insertion_node: '.qandasquestions', association_insertion_method: :append} %>
<%= link_to 'Back', qandas_path, class: "btn btn-default" %>
<%= f.input :company, :as => :hidden, :input_html => {:value => current_user.company} %>
</div>
</div>
<% end %>
Controller:
def index
@qandas = Qanda.all
respond_to do |format|
@qandas = Qanda.all
format.html
format.json
end
end
def create
@qanda = current_user.qandas.build(qanda_params)
respond_to do |format|
if @qanda.save!
@qandas = Qanda.all
format.html { redirect_to @qanda, notice: 'Qanda was successfully created.' }
format.json {render :layout => false}
else
format.html { render :new }
format.json { render json: @qanda.errors, status: :unprocessable_entity }
end
end
end
create.js.erb
$('#qandas').html("<%= j render partial: 'qandas/qanda' %>");
$('#qanda-form').slideUp(350);
new.js.erb
$('#qanda-form').html("<%= j render 'qandas/form' %>");
$('#qanda-form').slideDown(350);
Anybody can see why the Ajax does not kick off please? why am I redirected to the traditional SHOW page please?
ruby-on-rails
add a comment |
up vote
-1
down vote
favorite
I am trying to build a Q&A app with Ajax on the Index.html.erb. I manage to get the form remotely loading, but when saving the records, the AJAX does not work and the user is taken to the normal show.html.erb. Apart from the Ajax not kicking off, everything works well.
My code is as below:
index.html.erb (Contain a partial for input, and a partial for results)
<div>
<h3 class="section_title"> Q&A </h3>
<hr>
<div id="qanda-form" style="display:none;"> </div>
</div>
<div id="qandas">
<%= render 'qandas/qanda' %>
</div>
_qanda.html.erb (is the partial for results)
<% @qandas.each do |my_qanda| %>
<div class="col-md-9">
<div>
Created <%= local_time(my_qanda.created_at) %>, by <%= User.find_by(id: my_qanda.user_id).full_name %>
</div>
</div>
<% end %>
_form.html.erb (is the input form - has nested form via Cocoon)
<%= simple_form_for @qanda, remote: true do |f| %>
<%= f.error_notification %>
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
<div class="col-md-12 form-inputs">
<div class="col-md-8">
<%= f.input :title, label: 'Q&A Title:' %>
</div>
</div>
<div class="qandasquestions">
<%= f.simple_fields_for :qandasquestions do |builder| %>
<% render 'qandas/qandasquestion_fields', f: builder %>
<% end %>
<div class="links btn-group" style="min-height: 34px !important">
<%= f.button :submit, "Publish Q&A", class: "btn btn-default" %>
<%= link_to_add_association 'Add Question', f, :qandasquestions, class: 'btn btn-default', data: {association_insertion_node: '.qandasquestions', association_insertion_method: :append} %>
<%= link_to 'Back', qandas_path, class: "btn btn-default" %>
<%= f.input :company, :as => :hidden, :input_html => {:value => current_user.company} %>
</div>
</div>
<% end %>
Controller:
def index
@qandas = Qanda.all
respond_to do |format|
@qandas = Qanda.all
format.html
format.json
end
end
def create
@qanda = current_user.qandas.build(qanda_params)
respond_to do |format|
if @qanda.save!
@qandas = Qanda.all
format.html { redirect_to @qanda, notice: 'Qanda was successfully created.' }
format.json {render :layout => false}
else
format.html { render :new }
format.json { render json: @qanda.errors, status: :unprocessable_entity }
end
end
end
create.js.erb
$('#qandas').html("<%= j render partial: 'qandas/qanda' %>");
$('#qanda-form').slideUp(350);
new.js.erb
$('#qanda-form').html("<%= j render 'qandas/form' %>");
$('#qanda-form').slideDown(350);
Anybody can see why the Ajax does not kick off please? why am I redirected to the traditional SHOW page please?
ruby-on-rails
the request you're sending is ofjs
notjson
so removeformat.html
andformat.json
and just writeformat.js
and your instance variable will be available increate.js.erb
as well.
– Gagan Gupta
Nov 9 at 6:51
Hey Gagan, thanks a lot. I made the change and get the following error :ActionController::UnknownFormat Extracted source (around line #38): end end respond_to do |format| @qandas = Qanda.all format.js
– Etienne
Nov 9 at 14:15
I m sure this must not be difficult, certainly I am missing a small point.
– Etienne
Nov 9 at 21:18
@GaganGupta, what do you mean by "your instance variable will be available in create.js.erb as well."?
– Etienne
Nov 10 at 22:01
@qanda
and@qandas
are instance variables and they'll be available on views as well. Here the view would becreate.js.erb
. umm, I am posting an answer as I cannot write the code here. just let me know if it is working
– Gagan Gupta
Nov 10 at 22:03
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am trying to build a Q&A app with Ajax on the Index.html.erb. I manage to get the form remotely loading, but when saving the records, the AJAX does not work and the user is taken to the normal show.html.erb. Apart from the Ajax not kicking off, everything works well.
My code is as below:
index.html.erb (Contain a partial for input, and a partial for results)
<div>
<h3 class="section_title"> Q&A </h3>
<hr>
<div id="qanda-form" style="display:none;"> </div>
</div>
<div id="qandas">
<%= render 'qandas/qanda' %>
</div>
_qanda.html.erb (is the partial for results)
<% @qandas.each do |my_qanda| %>
<div class="col-md-9">
<div>
Created <%= local_time(my_qanda.created_at) %>, by <%= User.find_by(id: my_qanda.user_id).full_name %>
</div>
</div>
<% end %>
_form.html.erb (is the input form - has nested form via Cocoon)
<%= simple_form_for @qanda, remote: true do |f| %>
<%= f.error_notification %>
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
<div class="col-md-12 form-inputs">
<div class="col-md-8">
<%= f.input :title, label: 'Q&A Title:' %>
</div>
</div>
<div class="qandasquestions">
<%= f.simple_fields_for :qandasquestions do |builder| %>
<% render 'qandas/qandasquestion_fields', f: builder %>
<% end %>
<div class="links btn-group" style="min-height: 34px !important">
<%= f.button :submit, "Publish Q&A", class: "btn btn-default" %>
<%= link_to_add_association 'Add Question', f, :qandasquestions, class: 'btn btn-default', data: {association_insertion_node: '.qandasquestions', association_insertion_method: :append} %>
<%= link_to 'Back', qandas_path, class: "btn btn-default" %>
<%= f.input :company, :as => :hidden, :input_html => {:value => current_user.company} %>
</div>
</div>
<% end %>
Controller:
def index
@qandas = Qanda.all
respond_to do |format|
@qandas = Qanda.all
format.html
format.json
end
end
def create
@qanda = current_user.qandas.build(qanda_params)
respond_to do |format|
if @qanda.save!
@qandas = Qanda.all
format.html { redirect_to @qanda, notice: 'Qanda was successfully created.' }
format.json {render :layout => false}
else
format.html { render :new }
format.json { render json: @qanda.errors, status: :unprocessable_entity }
end
end
end
create.js.erb
$('#qandas').html("<%= j render partial: 'qandas/qanda' %>");
$('#qanda-form').slideUp(350);
new.js.erb
$('#qanda-form').html("<%= j render 'qandas/form' %>");
$('#qanda-form').slideDown(350);
Anybody can see why the Ajax does not kick off please? why am I redirected to the traditional SHOW page please?
ruby-on-rails
I am trying to build a Q&A app with Ajax on the Index.html.erb. I manage to get the form remotely loading, but when saving the records, the AJAX does not work and the user is taken to the normal show.html.erb. Apart from the Ajax not kicking off, everything works well.
My code is as below:
index.html.erb (Contain a partial for input, and a partial for results)
<div>
<h3 class="section_title"> Q&A </h3>
<hr>
<div id="qanda-form" style="display:none;"> </div>
</div>
<div id="qandas">
<%= render 'qandas/qanda' %>
</div>
_qanda.html.erb (is the partial for results)
<% @qandas.each do |my_qanda| %>
<div class="col-md-9">
<div>
Created <%= local_time(my_qanda.created_at) %>, by <%= User.find_by(id: my_qanda.user_id).full_name %>
</div>
</div>
<% end %>
_form.html.erb (is the input form - has nested form via Cocoon)
<%= simple_form_for @qanda, remote: true do |f| %>
<%= f.error_notification %>
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
<div class="col-md-12 form-inputs">
<div class="col-md-8">
<%= f.input :title, label: 'Q&A Title:' %>
</div>
</div>
<div class="qandasquestions">
<%= f.simple_fields_for :qandasquestions do |builder| %>
<% render 'qandas/qandasquestion_fields', f: builder %>
<% end %>
<div class="links btn-group" style="min-height: 34px !important">
<%= f.button :submit, "Publish Q&A", class: "btn btn-default" %>
<%= link_to_add_association 'Add Question', f, :qandasquestions, class: 'btn btn-default', data: {association_insertion_node: '.qandasquestions', association_insertion_method: :append} %>
<%= link_to 'Back', qandas_path, class: "btn btn-default" %>
<%= f.input :company, :as => :hidden, :input_html => {:value => current_user.company} %>
</div>
</div>
<% end %>
Controller:
def index
@qandas = Qanda.all
respond_to do |format|
@qandas = Qanda.all
format.html
format.json
end
end
def create
@qanda = current_user.qandas.build(qanda_params)
respond_to do |format|
if @qanda.save!
@qandas = Qanda.all
format.html { redirect_to @qanda, notice: 'Qanda was successfully created.' }
format.json {render :layout => false}
else
format.html { render :new }
format.json { render json: @qanda.errors, status: :unprocessable_entity }
end
end
end
create.js.erb
$('#qandas').html("<%= j render partial: 'qandas/qanda' %>");
$('#qanda-form').slideUp(350);
new.js.erb
$('#qanda-form').html("<%= j render 'qandas/form' %>");
$('#qanda-form').slideDown(350);
Anybody can see why the Ajax does not kick off please? why am I redirected to the traditional SHOW page please?
ruby-on-rails
ruby-on-rails
edited Nov 9 at 5:12
Ilya Konyukhov
2,183618
2,183618
asked Nov 9 at 3:26
Etienne
946
946
the request you're sending is ofjs
notjson
so removeformat.html
andformat.json
and just writeformat.js
and your instance variable will be available increate.js.erb
as well.
– Gagan Gupta
Nov 9 at 6:51
Hey Gagan, thanks a lot. I made the change and get the following error :ActionController::UnknownFormat Extracted source (around line #38): end end respond_to do |format| @qandas = Qanda.all format.js
– Etienne
Nov 9 at 14:15
I m sure this must not be difficult, certainly I am missing a small point.
– Etienne
Nov 9 at 21:18
@GaganGupta, what do you mean by "your instance variable will be available in create.js.erb as well."?
– Etienne
Nov 10 at 22:01
@qanda
and@qandas
are instance variables and they'll be available on views as well. Here the view would becreate.js.erb
. umm, I am posting an answer as I cannot write the code here. just let me know if it is working
– Gagan Gupta
Nov 10 at 22:03
add a comment |
the request you're sending is ofjs
notjson
so removeformat.html
andformat.json
and just writeformat.js
and your instance variable will be available increate.js.erb
as well.
– Gagan Gupta
Nov 9 at 6:51
Hey Gagan, thanks a lot. I made the change and get the following error :ActionController::UnknownFormat Extracted source (around line #38): end end respond_to do |format| @qandas = Qanda.all format.js
– Etienne
Nov 9 at 14:15
I m sure this must not be difficult, certainly I am missing a small point.
– Etienne
Nov 9 at 21:18
@GaganGupta, what do you mean by "your instance variable will be available in create.js.erb as well."?
– Etienne
Nov 10 at 22:01
@qanda
and@qandas
are instance variables and they'll be available on views as well. Here the view would becreate.js.erb
. umm, I am posting an answer as I cannot write the code here. just let me know if it is working
– Gagan Gupta
Nov 10 at 22:03
the request you're sending is of
js
not json
so remove format.html
and format.json
and just write format.js
and your instance variable will be available in create.js.erb
as well.– Gagan Gupta
Nov 9 at 6:51
the request you're sending is of
js
not json
so remove format.html
and format.json
and just write format.js
and your instance variable will be available in create.js.erb
as well.– Gagan Gupta
Nov 9 at 6:51
Hey Gagan, thanks a lot. I made the change and get the following error :
ActionController::UnknownFormat Extracted source (around line #38): end end respond_to do |format| @qandas = Qanda.all format.js
– Etienne
Nov 9 at 14:15
Hey Gagan, thanks a lot. I made the change and get the following error :
ActionController::UnknownFormat Extracted source (around line #38): end end respond_to do |format| @qandas = Qanda.all format.js
– Etienne
Nov 9 at 14:15
I m sure this must not be difficult, certainly I am missing a small point.
– Etienne
Nov 9 at 21:18
I m sure this must not be difficult, certainly I am missing a small point.
– Etienne
Nov 9 at 21:18
@GaganGupta, what do you mean by "your instance variable will be available in create.js.erb as well."?
– Etienne
Nov 10 at 22:01
@GaganGupta, what do you mean by "your instance variable will be available in create.js.erb as well."?
– Etienne
Nov 10 at 22:01
@qanda
and @qandas
are instance variables and they'll be available on views as well. Here the view would be create.js.erb
. umm, I am posting an answer as I cannot write the code here. just let me know if it is working– Gagan Gupta
Nov 10 at 22:03
@qanda
and @qandas
are instance variables and they'll be available on views as well. Here the view would be create.js.erb
. umm, I am posting an answer as I cannot write the code here. just let me know if it is working– Gagan Gupta
Nov 10 at 22:03
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Try updating your code to this and let me know if it's working?
def create
@qanda = current_user.qandas.build(qanda_params)
if @qanda.save!
@qandas = Qanda.all
else
@errors = @qanda.errors
end
end
It is working now, there were a few other things to change, you put me in the right direction again. thank you . Last one, do you know why best_in_place does not work on the view generated via AJAX ? It was working when Ajax was broken, now Ajax is fixed and best_in _place no longer works.
– Etienne
Nov 10 at 22:26
I am glad you got it working, what do you mean bybest_in_place
?
– Gagan Gupta
Nov 10 at 22:29
If you've got time, try to dig deeper why your code wasn't working. format.js expects some arguments. example:format.js { render 'create', locals: { qanda: @qanda, qandas: @qandas } }
but do it later when you get it working perfectly, not now :D
– Gagan Gupta
Nov 10 at 22:32
1
Sure. It was the good opportunity as well to understand the whole render/remote process.
– Etienne
Nov 10 at 22:38
what's best_in_place?
– Gagan Gupta
Nov 10 at 22:40
|
show 3 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Try updating your code to this and let me know if it's working?
def create
@qanda = current_user.qandas.build(qanda_params)
if @qanda.save!
@qandas = Qanda.all
else
@errors = @qanda.errors
end
end
It is working now, there were a few other things to change, you put me in the right direction again. thank you . Last one, do you know why best_in_place does not work on the view generated via AJAX ? It was working when Ajax was broken, now Ajax is fixed and best_in _place no longer works.
– Etienne
Nov 10 at 22:26
I am glad you got it working, what do you mean bybest_in_place
?
– Gagan Gupta
Nov 10 at 22:29
If you've got time, try to dig deeper why your code wasn't working. format.js expects some arguments. example:format.js { render 'create', locals: { qanda: @qanda, qandas: @qandas } }
but do it later when you get it working perfectly, not now :D
– Gagan Gupta
Nov 10 at 22:32
1
Sure. It was the good opportunity as well to understand the whole render/remote process.
– Etienne
Nov 10 at 22:38
what's best_in_place?
– Gagan Gupta
Nov 10 at 22:40
|
show 3 more comments
up vote
1
down vote
accepted
Try updating your code to this and let me know if it's working?
def create
@qanda = current_user.qandas.build(qanda_params)
if @qanda.save!
@qandas = Qanda.all
else
@errors = @qanda.errors
end
end
It is working now, there were a few other things to change, you put me in the right direction again. thank you . Last one, do you know why best_in_place does not work on the view generated via AJAX ? It was working when Ajax was broken, now Ajax is fixed and best_in _place no longer works.
– Etienne
Nov 10 at 22:26
I am glad you got it working, what do you mean bybest_in_place
?
– Gagan Gupta
Nov 10 at 22:29
If you've got time, try to dig deeper why your code wasn't working. format.js expects some arguments. example:format.js { render 'create', locals: { qanda: @qanda, qandas: @qandas } }
but do it later when you get it working perfectly, not now :D
– Gagan Gupta
Nov 10 at 22:32
1
Sure. It was the good opportunity as well to understand the whole render/remote process.
– Etienne
Nov 10 at 22:38
what's best_in_place?
– Gagan Gupta
Nov 10 at 22:40
|
show 3 more comments
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Try updating your code to this and let me know if it's working?
def create
@qanda = current_user.qandas.build(qanda_params)
if @qanda.save!
@qandas = Qanda.all
else
@errors = @qanda.errors
end
end
Try updating your code to this and let me know if it's working?
def create
@qanda = current_user.qandas.build(qanda_params)
if @qanda.save!
@qandas = Qanda.all
else
@errors = @qanda.errors
end
end
answered Nov 10 at 22:11
Gagan Gupta
750317
750317
It is working now, there were a few other things to change, you put me in the right direction again. thank you . Last one, do you know why best_in_place does not work on the view generated via AJAX ? It was working when Ajax was broken, now Ajax is fixed and best_in _place no longer works.
– Etienne
Nov 10 at 22:26
I am glad you got it working, what do you mean bybest_in_place
?
– Gagan Gupta
Nov 10 at 22:29
If you've got time, try to dig deeper why your code wasn't working. format.js expects some arguments. example:format.js { render 'create', locals: { qanda: @qanda, qandas: @qandas } }
but do it later when you get it working perfectly, not now :D
– Gagan Gupta
Nov 10 at 22:32
1
Sure. It was the good opportunity as well to understand the whole render/remote process.
– Etienne
Nov 10 at 22:38
what's best_in_place?
– Gagan Gupta
Nov 10 at 22:40
|
show 3 more comments
It is working now, there were a few other things to change, you put me in the right direction again. thank you . Last one, do you know why best_in_place does not work on the view generated via AJAX ? It was working when Ajax was broken, now Ajax is fixed and best_in _place no longer works.
– Etienne
Nov 10 at 22:26
I am glad you got it working, what do you mean bybest_in_place
?
– Gagan Gupta
Nov 10 at 22:29
If you've got time, try to dig deeper why your code wasn't working. format.js expects some arguments. example:format.js { render 'create', locals: { qanda: @qanda, qandas: @qandas } }
but do it later when you get it working perfectly, not now :D
– Gagan Gupta
Nov 10 at 22:32
1
Sure. It was the good opportunity as well to understand the whole render/remote process.
– Etienne
Nov 10 at 22:38
what's best_in_place?
– Gagan Gupta
Nov 10 at 22:40
It is working now, there were a few other things to change, you put me in the right direction again. thank you . Last one, do you know why best_in_place does not work on the view generated via AJAX ? It was working when Ajax was broken, now Ajax is fixed and best_in _place no longer works.
– Etienne
Nov 10 at 22:26
It is working now, there were a few other things to change, you put me in the right direction again. thank you . Last one, do you know why best_in_place does not work on the view generated via AJAX ? It was working when Ajax was broken, now Ajax is fixed and best_in _place no longer works.
– Etienne
Nov 10 at 22:26
I am glad you got it working, what do you mean by
best_in_place
?– Gagan Gupta
Nov 10 at 22:29
I am glad you got it working, what do you mean by
best_in_place
?– Gagan Gupta
Nov 10 at 22:29
If you've got time, try to dig deeper why your code wasn't working. format.js expects some arguments. example:
format.js { render 'create', locals: { qanda: @qanda, qandas: @qandas } }
but do it later when you get it working perfectly, not now :D– Gagan Gupta
Nov 10 at 22:32
If you've got time, try to dig deeper why your code wasn't working. format.js expects some arguments. example:
format.js { render 'create', locals: { qanda: @qanda, qandas: @qandas } }
but do it later when you get it working perfectly, not now :D– Gagan Gupta
Nov 10 at 22:32
1
1
Sure. It was the good opportunity as well to understand the whole render/remote process.
– Etienne
Nov 10 at 22:38
Sure. It was the good opportunity as well to understand the whole render/remote process.
– Etienne
Nov 10 at 22:38
what's best_in_place?
– Gagan Gupta
Nov 10 at 22:40
what's best_in_place?
– Gagan Gupta
Nov 10 at 22:40
|
show 3 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53219426%2fajax-not-working-in-rails-same-page-update%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
the request you're sending is of
js
notjson
so removeformat.html
andformat.json
and just writeformat.js
and your instance variable will be available increate.js.erb
as well.– Gagan Gupta
Nov 9 at 6:51
Hey Gagan, thanks a lot. I made the change and get the following error :
ActionController::UnknownFormat Extracted source (around line #38): end end respond_to do |format| @qandas = Qanda.all format.js
– Etienne
Nov 9 at 14:15
I m sure this must not be difficult, certainly I am missing a small point.
– Etienne
Nov 9 at 21:18
@GaganGupta, what do you mean by "your instance variable will be available in create.js.erb as well."?
– Etienne
Nov 10 at 22:01
@qanda
and@qandas
are instance variables and they'll be available on views as well. Here the view would becreate.js.erb
. umm, I am posting an answer as I cannot write the code here. just let me know if it is working– Gagan Gupta
Nov 10 at 22:03