bootstrap_admin 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -132,12 +132,19 @@ module BootstrapAdminHelper
132
132
 
133
133
  def bootstrap_url_for options = {}
134
134
  defaults = {:controller => params[:controller]}.merge options
135
- url_for(defaults)
135
+
136
+ ctrl_namespace = defaults[:controller].split("/").first
137
+ if instance_eval "defined? #{ctrl_namespace}"
138
+ instance_eval("#{ctrl_namespace}.method :url_for").call defaults
139
+ else
140
+ main_app.url_for(defaults)
141
+ end
136
142
  end
137
143
  alias_method :bootstrap_url, :bootstrap_url_for
138
144
 
139
145
  def bootstrap_form_url item
140
- [item, :url => bootstrap_url_for(:action => (item.new_record? ? :create : :update), :id => item.id)]
146
+ item_name = item.class.name.underscore.gsub("/","_")
147
+ [item, :as => item_name, :url => bootstrap_url_for(:action => (item.new_record? ? :create : :update), :id => item.id)]
141
148
  end
142
149
 
143
150
  # =============================================================================
@@ -22,6 +22,7 @@ module BootstrapAdmin
22
22
  if request.xhr?
23
23
  render controller.params[:action], layout: false
24
24
  end
25
+
25
26
  elsif resource.is_a?(ActiveRecord::Base) && (post? || put?) && resource.valid?
26
27
  message = if post?
27
28
  'helpers.messages.create.success'
@@ -29,12 +30,12 @@ module BootstrapAdmin
29
30
  'helpers.messages.update.success'
30
31
  end
31
32
  controller.flash[:success] = I18n.t(message, :model => resource.class.model_name.human)
32
- redirect_to :controller => controller.controller_name, :action => :show, :id => resource.id
33
+ redirect_to :action => :show, :id => resource.id
33
34
 
34
35
  else
35
36
  if delete?
36
37
  controller.flash[:success] = I18n.t("helpers.messages.destroy.success", :model => resource.class.model_name.human)
37
- redirect_to :controller => controller.controller_name
38
+ redirect_to :action => :index
38
39
  else
39
40
  super
40
41
  end
@@ -1,3 +1,3 @@
1
1
  module BootstrapAdmin
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-05-21 00:00:00.000000000 Z
13
+ date: 2013-05-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails