Commit bac1199247edc7ddacb7d74d2607664d90747b99

Authored by Rodrigo Souto
Committed by Daniela Feitosa
1 parent 96098b34

[multiples-templates] Fixing redirect action and template_id param

app/controllers/admin/templates_controller.rb
@@ -9,7 +9,7 @@ class TemplatesController < AdminController @@ -9,7 +9,7 @@ class TemplatesController < AdminController
9 template = User.new(:login => identifier, :email => identifier+'@templates.noo', :password => password, :password_confirmation => password, :person_data => {:name => params[:name], :is_template => true}) 9 template = User.new(:login => identifier, :email => identifier+'@templates.noo', :password => password, :password_confirmation => password, :person_data => {:name => params[:name], :is_template => true})
10 template.save! 10 template.save!
11 session[:notice] = _('New template created') 11 session[:notice] = _('New template created')
12 - redirect_to :action => 'edit_templates' 12 + redirect_to :action => 'index'
13 rescue 13 rescue
14 @error = _('Name has already been taken') 14 @error = _('Name has already been taken')
15 end 15 end
@@ -21,7 +21,7 @@ class TemplatesController < AdminController @@ -21,7 +21,7 @@ class TemplatesController < AdminController
21 begin 21 begin
22 create_organization_template(Community) 22 create_organization_template(Community)
23 session[:notice] = _('New template created') 23 session[:notice] = _('New template created')
24 - redirect_to :action => 'edit_templates' 24 + redirect_to :action => 'index'
25 rescue 25 rescue
26 @error = _('Name has already been taken') 26 @error = _('Name has already been taken')
27 end 27 end
@@ -33,7 +33,7 @@ class TemplatesController < AdminController @@ -33,7 +33,7 @@ class TemplatesController < AdminController
33 begin 33 begin
34 create_organization_template(Enterprise) 34 create_organization_template(Enterprise)
35 session[:notice] = _('New template created') 35 session[:notice] = _('New template created')
36 - redirect_to :action => 'edit_templates' 36 + redirect_to :action => 'index'
37 rescue 37 rescue
38 @error = _('Name has already been taken') 38 @error = _('Name has already been taken')
39 end 39 end
app/helpers/application_helper.rb
@@ -1333,7 +1333,7 @@ module ApplicationHelper @@ -1333,7 +1333,7 @@ module ApplicationHelper
1333 end 1333 end
1334 1334
1335 def template_options(klass, field_name) 1335 def template_options(klass, field_name)
1336 - return hidden_field_tag("#{field_name}[template_id]", klass.templates.first) if klass.templates.count == 1 1336 + return hidden_field_tag("#{field_name}[template_id]", klass.templates.first.id) if klass.templates.count == 1
1337 1337
1338 counter = 0 1338 counter = 0
1339 radios = klass.templates.map do |template| 1339 radios = klass.templates.map do |template|