I have a table in my database and I'm showing in a page.
The problem happens when I am saving the changes.
I need the Rails process using js and not redirect the user to another page when you click save.
So far, I can save changes but I am always redirected to other pages processed by HTML instead JS.
controller:
filter_resource_access :nested_in => :releases
filter_resource_access :nested_in => :project
respond_to :js, only: [:update, :edit, :show]
respond_to :html
before_filter :load_issue, :load_project, :load_release
def edit
end
def update
if @issue_value.update_attributes(params[:issue_value])
flash.now[:notice] = t('messages.successfully_updated_entity.f',
:entity => IssueValue.model_name.human)
respond_to do |format|
format.js
end
end
end
_issue_values_table:
<table class="zebra-striped">
<thead>
<tr>
<th><%= IssueValue.human_attribute_name :name %></th>
<th><%= IssueValue.human_attribute_name :value %></th>
<th><%= IssueValue.human_attribute_name :client_value %></th>
<th></th>
</tr>
</thead>
<tbody>
<% @issue_types = IssueType %>
<% for issue_value in @release.issue_values.order("issue_type_id") %>
<%= content_tag_for :tr, issue_value, :class => "clickable" do %>
<td width="42%"><%#= t(@issue_types.find(issue_value.issue_type_id).label_key) %></td>
<td width="20%">
<%= number_to_currency issue_value.value %>
</td>
<td width="20%">
<%= number_to_currency issue_value.client_value %>
</td>
<td width="12%" class="icons right">
<%= edit_icon issue_value, [:edit, @project, @release, issue_value], :remote => true, 'data-default-action' => true %>
</td>
<% end %>
<% end %>
</tbody>
_form_row:
<td colspan="4">
<%= form_for [@project, @release, @issue_value], :remote => true, :html => {:style => "margin:0"} do |f| %>
<table class="basic">
<tr>
<td class="span8 middle">
<div class="clearfix">
<%#= f.text_field :name, :placeholder => IssueType.human_attribute_name(:name),
:autofocus => true, :class => "span10" %>
</div>
</td>
<td class="span5 middle">
<div class="clearfix">
<%= f.text_field :value, :placeholder => IssueValue.human_attribute_name(:value),
:autofocus => true, :class => "span2" %>
</div>
</td>
<td class="span5 middle">
<div class="clearfix">
<%= f.text_field :client_value, :placeholder => IssueValue.human_attribute_name(:client_value),
:class => "span2" %>
</div>
</td>
<td class="span2 icons">
<%= f.submit t('actions.save'), :disable_with => t('messages.please_wait'), :class => 'btn small', :remote => true %>
</td>
</tr>
</table>
<% end %>
In views/issue_values I have:
edit.js.erb
show.js.erb
update.js.erb
_form_row.html.erb
_issue_values_table.html.erb
Well, I don't undestand why this not works.
The Log is:
Started GET "/projects/pro-/releases/release02/values/14/edit" for 127.0.0.1 at 2013-12-13 08:39:36 -0200 Processing by IssueValuesController#edit as JS Parameters: {"project_id"=>"pro-", "release_id"=>"release02", "id"=>"14"} SQL (0.5ms) SHOW TABLES User Load (0.1ms) SELECT
users
.* FROMusers
WHERE ((users
.auth_token
= 'ji2lt8p1185q6q1l' ANDusers
.status_id
= 2)) LIMIT 1 SQL (1.5ms) describereleases_browser_versions
SQL (0.6ms) describereleases_os_versions
SQL (0.7ms) describereleases_mobile_models
Release Load (0.1ms) SELECTreleases
.* FROMreleases
WHEREreleases
.identifier
= 'release02' LIMIT 1 IssueValue Load (0.1ms) SELECTissue_values
.* FROMissue_values
WHEREissue_values
.id
= 14 LIMIT 1 SQL (0.6ms) SHOW TABLES Project Load (0.1ms) SELECTprojects
.* FROMprojects
WHEREprojects
.identifier
= 'pro-' LIMIT 1 CACHE (0.0ms) SELECTissue_values
.* FROMissue_values
WHEREissue_values
.id
= 14 LIMIT 1 Rendered issue_values/_form_row.html.erb (34.6ms) Rendered issue_values/edit.js.erb (36.1ms) Completed 200 OK in 642ms (Views: 50.4ms | ActiveRecord: 4.3ms) [2013-12-13 08:39:36] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = trueStarted POST "/projects/pro-/releases/release02/values/14" for 127.0.0.1 at 2013-12-13 08:39:37 -0200 Processing by IssueValuesController#update as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"vuyP9Jwm4pS63OF7xucBHGo0L5m61ayj3aWcXYpFTKM=", "issue_value"=>{"value"=>"10,00", "client_value"=>"5,00"}, "commit"=>"Salvar", "project_id"=>"pro-", "release_id"=>"release02", "id"=>"14"} SQL (0.5ms) SHOW TABLES User Load (0.1ms) SELECT
users
.* FROMusers
WHERE ((users
.auth_token
= 'ji2lt8p1185q6q1l' ANDusers
.status_id
= 2)) LIMIT 1 SQL (0.7ms) describereleases_browser_versions
SQL (0.5ms) describereleases_os_versions
SQL (0.6ms) describereleases_mobile_models
Release Load (0.1ms) SELECTreleases
.* FROMreleases
WHEREreleases
.identifier
= 'release02' LIMIT 1 IssueValue Load (0.2ms) SELECTissue_values
.* FROMissue_values
WHEREissue_values
.id
= 14 LIMIT 1 SQL (0.5ms) SHOW TABLES Project Load (0.1ms) SELECTprojects
.* FROMprojects
WHEREprojects
.identifier
= 'pro-' LIMIT 1 CACHE (0.0ms) SELECTissue_values
.* FROMissue_values
WHEREissue_values
.id
= 14 LIMIT 1 SQL (0.1ms) BEGIN SQL (0.1ms) COMMIT Completed 500 Internal Server Error in 784msActionView::MissingTemplate (Missing template issue_values/show with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:html], :locale=>[:pt, :pt]} in view paths "/var/www/base2_crowdtest/2112/final/trunk/app/views", "/usr/local/rvm/gems/ruby-1.9.3-p448/gems/client_side_validations-3.1.4/app/views", "/usr/local/rvm/gems/ruby-1.9.3-p448/gems/declarative_authorization-0.5.6/app/views", "/usr/local/rvm/gems/ruby-1.9.3-p448/gems/kaminari-0.13.0/app/views"): app/controllers/issue_values_controller.rb:12:in
block (3 levels) in update' app/controllers/issue_values_controller.rb:11:in
block in update' app/controllers/issue_values_controller.rb:9:in `update'Rendered /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/missing_template.erb within rescues/layout (0.8ms)
Someone help me?