nifty-generators 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +15 -0
- data/Gemfile.lock +1 -1
- data/features/nifty_authentication.feature +6 -3
- data/features/nifty_scaffold.feature +6 -0
- data/features/step_definitions/common_steps.rb +8 -0
- data/lib/generators/nifty/authentication/templates/controller_authentication.rb +3 -4
- data/lib/generators/nifty/authentication/templates/sessions_controller.rb +5 -9
- data/lib/generators/nifty/authentication/templates/tests/rspec/sessions_controller.rb +2 -2
- data/lib/generators/nifty/authentication/templates/tests/rspec/users_controller.rb +2 -2
- data/lib/generators/nifty/authentication/templates/tests/shoulda/sessions_controller.rb +2 -2
- data/lib/generators/nifty/authentication/templates/tests/shoulda/user.rb +8 -8
- data/lib/generators/nifty/authentication/templates/tests/shoulda/users_controller.rb +2 -2
- data/lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb +2 -2
- data/lib/generators/nifty/authentication/templates/tests/testunit/user.rb +8 -8
- data/lib/generators/nifty/authentication/templates/tests/testunit/users_controller.rb +2 -2
- data/lib/generators/nifty/authentication/templates/user.rb +3 -7
- data/lib/generators/nifty/authentication/templates/users_controller.rb +2 -4
- data/lib/generators/nifty/layout/templates/error_messages_helper.rb +2 -2
- data/lib/generators/nifty/scaffold/scaffold_generator.rb +12 -13
- data/lib/generators/nifty/scaffold/templates/actions/create.rb +1 -2
- data/lib/generators/nifty/scaffold/templates/actions/destroy.rb +1 -2
- data/lib/generators/nifty/scaffold/templates/actions/update.rb +1 -2
- data/lib/generators/nifty/scaffold/templates/model.rb +1 -1
- data/lib/generators/nifty/scaffold/templates/views/haml/_form.html.haml +1 -1
- metadata +3 -3
data/CHANGELOG
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
0.4.5 (February 14, 2011)
|
2
|
+
|
3
|
+
* fixing user validation tests in nifty:authentication (thanks apocalyptiq) - issue #87
|
4
|
+
|
5
|
+
* fixing form generation when only new action exists for nifty scaffold (thanks gouravtiwari) - issue #83
|
6
|
+
|
7
|
+
* fixing spacing issue in nifty:scaffold model
|
8
|
+
|
9
|
+
* fixing instance instance variable in haml form for nifty:scaffold - issue #81
|
10
|
+
|
11
|
+
* improving redirect implementation in nifty authentication
|
12
|
+
|
13
|
+
* adding i18n to error_messages_for in nifty:layout (thanks nhocki)
|
14
|
+
|
15
|
+
|
1
16
|
0.4.4 (January 17, 2011)
|
2
17
|
|
3
18
|
* adding namespaces to nifty:scaffold (thanks DouglasMeyer) - issue #63
|
data/Gemfile.lock
CHANGED
@@ -5,7 +5,8 @@ Feature: Nifty Authentication Generator
|
|
5
5
|
|
6
6
|
Scenario: Generate default authentication
|
7
7
|
Given a new Rails app
|
8
|
-
When I
|
8
|
+
When I insert "root :to => 'users#new'" into "config/routes.rb" after line 1
|
9
|
+
And I run "rails g nifty:authentication"
|
9
10
|
Then I should see the following files
|
10
11
|
| app/models/user.rb |
|
11
12
|
| app/controllers/users_controller.rb |
|
@@ -37,7 +38,8 @@ Feature: Nifty Authentication Generator
|
|
37
38
|
|
38
39
|
Scenario: Generate named authentication
|
39
40
|
Given a new Rails app
|
40
|
-
When I
|
41
|
+
When I insert "root :to => 'accounts#new'" into "config/routes.rb" after line 1
|
42
|
+
And I run "rails g nifty:authentication Account CurrentSession"
|
41
43
|
Then I should see the following files
|
42
44
|
| app/models/account.rb |
|
43
45
|
| app/controllers/accounts_controller.rb |
|
@@ -64,7 +66,8 @@ Feature: Nifty Authentication Generator
|
|
64
66
|
|
65
67
|
Scenario: Generate named authentication with rspec
|
66
68
|
Given a new Rails app
|
67
|
-
When I
|
69
|
+
When I insert "root :to => 'accounts#new'" into "config/routes.rb" after line 1
|
70
|
+
And I run "rails g nifty:authentication Account CurrentSession --rspec"
|
68
71
|
Then I should see the following files
|
69
72
|
| spec/models/account_spec.rb |
|
70
73
|
| spec/controllers/accounts_controller_spec.rb |
|
@@ -72,3 +72,9 @@ Feature: Nifty Scaffold Generator
|
|
72
72
|
And I run "rake db:migrate"
|
73
73
|
And I should successfully run "rails g nifty:scaffold Admin::User -f --namespace_model"
|
74
74
|
Then I should successfully run "rake test"
|
75
|
+
|
76
|
+
Scenario: Given scaffold with a new and index action
|
77
|
+
Given a new Rails app
|
78
|
+
When I run "rails g nifty:scaffold Project name:string index new"
|
79
|
+
Then I should see "class Project" in file "app/models/project.rb"
|
80
|
+
And I should see "<%= form_for @project do |f| %>" in file "app/views/projects/new.html.erb"
|
@@ -15,6 +15,14 @@ When /^I replace "([^\"]*)" with "([^\"]*)" in file "([^\"]*)"$/ do |old_content
|
|
15
15
|
File.open(path, 'w') { |f| f.write(content) }
|
16
16
|
end
|
17
17
|
|
18
|
+
When /^I insert "([^\"]*)" into "([^\"]*)" after line (\d+)$/ do |content, short_path, after_line|
|
19
|
+
path = File.join(@current_directory, short_path)
|
20
|
+
File.should exist(path)
|
21
|
+
lines = File.read(path).split("\n")
|
22
|
+
lines[after_line.to_i, 0] = content
|
23
|
+
File.open(path, 'w') { |f| f.write(lines.join("\n")) }
|
24
|
+
end
|
25
|
+
|
18
26
|
Then /^I should see file "([^\"]*)"$/ do |path|
|
19
27
|
File.should exist(File.join(@current_directory, path))
|
20
28
|
end
|
@@ -42,14 +42,13 @@ module ControllerAuthentication
|
|
42
42
|
|
43
43
|
def login_required
|
44
44
|
unless logged_in?
|
45
|
-
flash[:error] = "You must first log in or sign up before accessing this page."
|
46
45
|
store_target_location
|
47
|
-
redirect_to login_url
|
46
|
+
redirect_to login_url, :alert => "You must first log in or sign up before accessing this page."
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
|
-
def redirect_to_target_or_default(default)
|
52
|
-
redirect_to(session[:return_to] || default)
|
50
|
+
def redirect_to_target_or_default(default, *args)
|
51
|
+
redirect_to(session[:return_to] || default, *args)
|
53
52
|
session[:return_to] = nil
|
54
53
|
end
|
55
54
|
|
@@ -7,8 +7,7 @@ class <%= session_plural_class_name %>Controller < ApplicationController
|
|
7
7
|
def create
|
8
8
|
@<%= session_singular_name %> = <%= session_class_name %>.new(params[:<%= session_singular_name %>])
|
9
9
|
if @<%= session_singular_name %>.save
|
10
|
-
|
11
|
-
redirect_to_target_or_default("/")
|
10
|
+
redirect_to_target_or_default root_url, :notice => "Logged in successfully."
|
12
11
|
else
|
13
12
|
render :action => 'new'
|
14
13
|
end
|
@@ -17,8 +16,7 @@ class <%= session_plural_class_name %>Controller < ApplicationController
|
|
17
16
|
def destroy
|
18
17
|
@<%= session_singular_name %> = <%= session_class_name %>.find
|
19
18
|
@<%= session_singular_name %>.destroy
|
20
|
-
|
21
|
-
redirect_to "/"
|
19
|
+
redirect_to root_url, :notice => "You have been logged out."
|
22
20
|
end
|
23
21
|
<%- else -%>
|
24
22
|
def new
|
@@ -28,18 +26,16 @@ class <%= session_plural_class_name %>Controller < ApplicationController
|
|
28
26
|
<%= user_singular_name %> = <%= user_class_name %>.authenticate(params[:login], params[:password])
|
29
27
|
if <%= user_singular_name %>
|
30
28
|
session[:<%= user_singular_name %>_id] = <%= user_singular_name %>.id
|
31
|
-
|
32
|
-
redirect_to_target_or_default("/")
|
29
|
+
redirect_to_target_or_default root_url, :notice => "Logged in successfully."
|
33
30
|
else
|
34
|
-
flash.now[:
|
31
|
+
flash.now[:alert] = "Invalid login or password."
|
35
32
|
render :action => 'new'
|
36
33
|
end
|
37
34
|
end
|
38
35
|
|
39
36
|
def destroy
|
40
37
|
session[:<%= user_singular_name %>_id] = nil
|
41
|
-
|
42
|
-
redirect_to "/"
|
38
|
+
redirect_to root_url, :notice => "You have been logged out."
|
43
39
|
end
|
44
40
|
<%- end -%>
|
45
41
|
end
|
@@ -18,7 +18,7 @@ describe <%= session_plural_class_name %>Controller do
|
|
18
18
|
|
19
19
|
it "create action should redirect when authentication is valid" do
|
20
20
|
post :create, :<%= session_singular_name %> => { :username => "foo", :password => "secret" }
|
21
|
-
response.should redirect_to(
|
21
|
+
response.should redirect_to(root_url)
|
22
22
|
<%= session_class_name %>.find.<%= user_singular_name %>.should == <%= user_plural_name %>(:foo)
|
23
23
|
end
|
24
24
|
<%- else -%>
|
@@ -32,7 +32,7 @@ describe <%= session_plural_class_name %>Controller do
|
|
32
32
|
it "create action should redirect when authentication is valid" do
|
33
33
|
<%= user_class_name %>.stubs(:authenticate).returns(<%= user_class_name %>.first)
|
34
34
|
post :create
|
35
|
-
response.should redirect_to(
|
35
|
+
response.should redirect_to(root_url)
|
36
36
|
session['<%= user_singular_name %>_id'].should == <%= user_class_name %>.first.id
|
37
37
|
end
|
38
38
|
<%- end -%>
|
@@ -18,7 +18,7 @@ describe <%= user_plural_class_name %>Controller do
|
|
18
18
|
it "create action should redirect when model is valid" do
|
19
19
|
<%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
|
20
20
|
post :create
|
21
|
-
response.should redirect_to(
|
21
|
+
response.should redirect_to(root_url)
|
22
22
|
<%- unless options[:authlogic] -%>
|
23
23
|
session['<%= user_singular_name %>_id'].should == assigns['<%= user_singular_name %>'].id
|
24
24
|
<%- end -%>
|
@@ -51,6 +51,6 @@ describe <%= user_plural_class_name %>Controller do
|
|
51
51
|
@controller.stubs(:current_<%= user_singular_name %>).returns(<%= user_class_name %>.first)
|
52
52
|
<%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
|
53
53
|
put :update, :id => "ignored"
|
54
|
-
response.should redirect_to(
|
54
|
+
response.should redirect_to(root_url)
|
55
55
|
end
|
56
56
|
end
|
@@ -18,7 +18,7 @@ class <%= session_plural_class_name %>ControllerTest < ActionController::TestCas
|
|
18
18
|
|
19
19
|
should "redirect when authentication is valid" do
|
20
20
|
post :create, :<%= session_singular_name %> => { :username => "foo", :password => "secret" }
|
21
|
-
assert_redirected_to
|
21
|
+
assert_redirected_to root_url
|
22
22
|
assert_equal <%= user_plural_name %>(:foo), <%= session_class_name %>.find.<%= user_singular_name %>
|
23
23
|
end
|
24
24
|
<%- else -%>
|
@@ -32,7 +32,7 @@ class <%= session_plural_class_name %>ControllerTest < ActionController::TestCas
|
|
32
32
|
should "redirect when authentication is valid" do
|
33
33
|
<%= user_class_name %>.stubs(:authenticate).returns(<%= user_class_name %>.first)
|
34
34
|
post :create
|
35
|
-
assert_redirected_to
|
35
|
+
assert_redirected_to root_url
|
36
36
|
assert_equal <%= user_class_name %>.first.id, session['<%= user_singular_name %>_id']
|
37
37
|
end
|
38
38
|
<%- end -%>
|
@@ -21,37 +21,37 @@ class <%= user_class_name %>Test < ActiveSupport::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
should "require username" do
|
24
|
-
|
24
|
+
assert_equal ["can't be blank"], new_<%= user_singular_name %>(:username => '').errors[:username]
|
25
25
|
end
|
26
26
|
|
27
27
|
should "require password" do
|
28
|
-
|
28
|
+
assert_equal ["can't be blank"], new_<%= user_singular_name %>(:password => '').errors[:password]
|
29
29
|
end
|
30
30
|
|
31
31
|
should "require well formed email" do
|
32
|
-
|
32
|
+
assert_equal ["is invalid"], new_<%= user_singular_name %>(:email => 'foo@bar@example.com').errors[:email]
|
33
33
|
end
|
34
34
|
|
35
35
|
should "validate uniqueness of email" do
|
36
36
|
new_<%= user_singular_name %>(:email => 'bar@example.com').save!
|
37
|
-
|
37
|
+
assert_equal ["has already been taken"], new_<%= user_singular_name %>(:email => 'bar@example.com').errors[:email]
|
38
38
|
end
|
39
39
|
|
40
40
|
should "validate uniqueness of username" do
|
41
41
|
new_<%= user_singular_name %>(:username => 'uniquename').save!
|
42
|
-
|
42
|
+
assert_equal ["has already been taken"], new_<%= user_singular_name %>(:username => 'uniquename').errors[:username]
|
43
43
|
end
|
44
44
|
|
45
45
|
should "not allow odd characters in username" do
|
46
|
-
|
46
|
+
assert_equal ["should only contain letters, numbers, or .-_@"], new_<%= user_singular_name %>(:username => 'odd ^&(@)').errors[:username]
|
47
47
|
end
|
48
48
|
|
49
49
|
should "validate password is longer than 3 characters" do
|
50
|
-
|
50
|
+
assert_equal ["is too short (minimum is 4 characters)"], new_<%= user_singular_name %>(:password => 'bad').errors[:password]
|
51
51
|
end
|
52
52
|
|
53
53
|
should "require matching password confirmation" do
|
54
|
-
|
54
|
+
assert_equal ["doesn't match confirmation"], new_<%= user_singular_name %>(:password_confirmation => 'nonmatching').errors[:password]
|
55
55
|
end
|
56
56
|
|
57
57
|
should "generate password hash and salt on create" do
|
@@ -18,7 +18,7 @@ class <%= user_plural_class_name %>ControllerTest < ActionController::TestCase
|
|
18
18
|
should "redirect when <%= user_singular_name %> is valid" do
|
19
19
|
<%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
|
20
20
|
post :create
|
21
|
-
assert_redirected_to
|
21
|
+
assert_redirected_to root_url
|
22
22
|
<%- unless options[:authlogic] -%>
|
23
23
|
assert_equal assigns['<%= user_singular_name %>'].id, session['<%= user_singular_name %>_id']
|
24
24
|
<%- end -%>
|
@@ -55,7 +55,7 @@ class <%= user_plural_class_name %>ControllerTest < ActionController::TestCase
|
|
55
55
|
@controller.stubs(:current_<%= user_singular_name %>).returns(<%= user_class_name %>.first)
|
56
56
|
<%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
|
57
57
|
put :update, :id => "ignored"
|
58
|
-
assert_redirected_to
|
58
|
+
assert_redirected_to root_url
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -15,7 +15,7 @@ class <%= session_plural_class_name %>ControllerTest < ActionController::TestCas
|
|
15
15
|
|
16
16
|
def test_create_valid
|
17
17
|
post :create, :<%= session_singular_name %> => { :username => "foo", :password => "secret" }
|
18
|
-
assert_redirected_to
|
18
|
+
assert_redirected_to root_url
|
19
19
|
assert_equal <%= user_plural_name %>(:foo), <%= session_class_name %>.find.<%= user_singular_name %>
|
20
20
|
end
|
21
21
|
<%- else -%>
|
@@ -29,7 +29,7 @@ class <%= session_plural_class_name %>ControllerTest < ActionController::TestCas
|
|
29
29
|
def test_create_valid
|
30
30
|
<%= user_class_name %>.stubs(:authenticate).returns(<%= user_class_name %>.first)
|
31
31
|
post :create
|
32
|
-
assert_redirected_to
|
32
|
+
assert_redirected_to root_url
|
33
33
|
assert_equal <%= user_class_name %>.first.id, session['<%= user_singular_name %>_id']
|
34
34
|
end
|
35
35
|
<%- end -%>
|
@@ -21,37 +21,37 @@ class <%= user_class_name %>Test < ActiveSupport::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_require_username
|
24
|
-
|
24
|
+
assert_equal ["can't be blank"], new_<%= user_singular_name %>(:username => '').errors[:username]
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_require_password
|
28
|
-
|
28
|
+
assert_equal ["can't be blank"], new_<%= user_singular_name %>(:password => '').errors[:password]
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_require_well_formed_email
|
32
|
-
|
32
|
+
assert_equal ["is invalid"], new_<%= user_singular_name %>(:email => 'foo@bar@example.com').errors[:email]
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_validate_uniqueness_of_email
|
36
36
|
new_<%= user_singular_name %>(:email => 'bar@example.com').save!
|
37
|
-
|
37
|
+
assert_equal ["has already been taken"], new_<%= user_singular_name %>(:email => 'bar@example.com').errors[:email]
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_validate_uniqueness_of_username
|
41
41
|
new_<%= user_singular_name %>(:username => 'uniquename').save!
|
42
|
-
|
42
|
+
assert_equal ["has already been taken"], new_<%= user_singular_name %>(:username => 'uniquename').errors[:username]
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_validate_odd_characters_in_username
|
46
|
-
|
46
|
+
assert_equal ["should only contain letters, numbers, or .-_@"], new_<%= user_singular_name %>(:username => 'odd ^&(@)').errors[:username]
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_validate_password_length
|
50
|
-
|
50
|
+
assert_equal ["is too short (minimum is 4 characters)"], new_<%= user_singular_name %>(:password => 'bad').errors[:password]
|
51
51
|
end
|
52
52
|
|
53
53
|
def test_require_matching_password_confirmation
|
54
|
-
|
54
|
+
assert_equal ["doesn't match confirmation"], new_<%= user_singular_name %>(:password_confirmation => 'nonmatching').errors[:password]
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_generate_password_hash_and_salt_on_create
|
@@ -15,7 +15,7 @@ class <%= user_plural_class_name %>ControllerTest < ActionController::TestCase
|
|
15
15
|
def test_create_valid
|
16
16
|
<%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
|
17
17
|
post :create
|
18
|
-
assert_redirected_to
|
18
|
+
assert_redirected_to root_url
|
19
19
|
<%- unless options[:authlogic] -%>
|
20
20
|
assert_equal assigns['<%= user_singular_name %>'].id, session['<%= user_singular_name %>_id']
|
21
21
|
<%- end -%>
|
@@ -48,6 +48,6 @@ class <%= user_plural_class_name %>ControllerTest < ActionController::TestCase
|
|
48
48
|
@controller.stubs(:current_<%= user_singular_name %>).returns(<%= user_class_name %>.first)
|
49
49
|
<%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
|
50
50
|
put :update, :id => "ignored"
|
51
|
-
assert_redirected_to
|
51
|
+
assert_redirected_to root_url
|
52
52
|
end
|
53
53
|
end
|
@@ -19,11 +19,11 @@ class <%= user_class_name %> < ActiveRecord::Base
|
|
19
19
|
# login can be either username or email address
|
20
20
|
def self.authenticate(login, pass)
|
21
21
|
<%= user_singular_name %> = find_by_username(login) || find_by_email(login)
|
22
|
-
return <%= user_singular_name %> if <%= user_singular_name %> && <%= user_singular_name %>.
|
22
|
+
return <%= user_singular_name %> if <%= user_singular_name %> && <%= user_singular_name %>.password_hash == <%= user_singular_name %>.encrypt_password(pass)
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
|
25
|
+
def encrypt_password(pass)
|
26
|
+
BCrypt::Engine.hash_secret(pass, password_salt)
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
@@ -34,9 +34,5 @@ class <%= user_class_name %> < ActiveRecord::Base
|
|
34
34
|
self.password_hash = encrypt_password(password)
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
38
|
-
def encrypt_password(pass)
|
39
|
-
BCrypt::Engine.hash_secret(pass, password_salt)
|
40
|
-
end
|
41
37
|
<%- end -%>
|
42
38
|
end
|
@@ -11,8 +11,7 @@ class <%= user_plural_class_name %>Controller < ApplicationController
|
|
11
11
|
<%- unless options[:authlogic] -%>
|
12
12
|
session[:<%= user_singular_name %>_id] = @<%= user_singular_name %>.id
|
13
13
|
<%- end -%>
|
14
|
-
|
15
|
-
redirect_to "/"
|
14
|
+
redirect_to root_url, :notice => "Thank you for signing up! You are now logged in."
|
16
15
|
else
|
17
16
|
render :action => 'new'
|
18
17
|
end
|
@@ -25,8 +24,7 @@ class <%= user_plural_class_name %>Controller < ApplicationController
|
|
25
24
|
def update
|
26
25
|
@<%= user_singular_name %> = current_<%= user_singular_name %>
|
27
26
|
if @<%= user_singular_name %>.update_attributes(params[:<%= user_singular_name %>])
|
28
|
-
|
29
|
-
redirect_to "/"
|
27
|
+
redirect_to root_url, :notice => "Your profile has been updated."
|
30
28
|
else
|
31
29
|
render :action => 'edit'
|
32
30
|
end
|
@@ -2,8 +2,8 @@ module ErrorMessagesHelper
|
|
2
2
|
# Render error messages for the given objects. The :message and :header_message options are allowed.
|
3
3
|
def error_messages_for(*objects)
|
4
4
|
options = objects.extract_options!
|
5
|
-
options[:header_message] ||= "Invalid Fields"
|
6
|
-
options[:message] ||= "Correct the following errors and try again."
|
5
|
+
options[:header_message] ||= I18n.t(:"activerecord.errors.header", :default => "Invalid Fields")
|
6
|
+
options[:message] ||= I18n.t(:"activerecord.errors.message", :default => "Correct the following errors and try again.")
|
7
7
|
messages = objects.compact.map { |o| o.errors.full_messages }.flatten
|
8
8
|
unless messages.empty?
|
9
9
|
content_tag(:div, :class => "error_messages") do
|
@@ -209,26 +209,25 @@ module Nifty
|
|
209
209
|
end
|
210
210
|
|
211
211
|
def item_path(options = {})
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
212
|
+
name = options[:instance_variable] ? "@#{instance_name}" : instance_name
|
213
|
+
suffix = options[:full_url] ? "url" : "path"
|
214
|
+
if options[:action].to_s == "new"
|
215
|
+
"new_#{item_resource}_#{suffix}"
|
216
|
+
elsif options[:action].to_s == "edit"
|
217
|
+
"edit_#{item_resource}_#{suffix}(#{name})"
|
218
|
+
else
|
219
|
+
if scaffold_name.include?('::') && !@namespace_model
|
220
|
+
namespace = singular_name.split('/')[0..-2]
|
221
|
+
"[:#{namespace.join(', :')}, #{name}]"
|
216
222
|
else
|
217
|
-
|
218
|
-
namespace = singular_name.split('/')[0..-2]
|
219
|
-
"[ :#{namespace.join(', :')}, #{name} ]"
|
220
|
-
else
|
221
|
-
name
|
222
|
-
end
|
223
|
+
name
|
223
224
|
end
|
224
|
-
else
|
225
|
-
items_path
|
226
225
|
end
|
227
226
|
end
|
228
227
|
|
229
228
|
def item_url
|
230
229
|
if action? :show
|
231
|
-
|
230
|
+
item_path(:full_url => true, :instance_variable => true)
|
232
231
|
else
|
233
232
|
items_url
|
234
233
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
def create
|
2
2
|
@<%= instance_name %> = <%= class_name %>.new(params[:<%= instance_name %>])
|
3
3
|
if @<%= instance_name %>.save
|
4
|
-
|
5
|
-
redirect_to <%= item_path :instance_variable => true %>
|
4
|
+
redirect_to <%= item_url %>, :notice => "Successfully created <%= class_name.underscore.humanize.downcase %>."
|
6
5
|
else
|
7
6
|
render :action => 'new'
|
8
7
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
def destroy
|
2
2
|
@<%= instance_name %> = <%= class_name %>.find(params[:id])
|
3
3
|
@<%= instance_name %>.destroy
|
4
|
-
|
5
|
-
redirect_to <%= items_url %>
|
4
|
+
redirect_to <%= items_url %>, :notice => "Successfully destroyed <%= class_name.underscore.humanize.downcase %>."
|
6
5
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
def update
|
2
2
|
@<%= instance_name %> = <%= class_name %>.find(params[:id])
|
3
3
|
if @<%= instance_name %>.update_attributes(params[:<%= instance_name %>])
|
4
|
-
|
5
|
-
redirect_to <%= item_url %>
|
4
|
+
redirect_to <%= item_url %>, :notice => "Successfully updated <%= class_name.underscore.humanize.downcase %>."
|
6
5
|
else
|
7
6
|
render :action => 'edit'
|
8
7
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 5
|
9
|
+
version: 0.4.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ryan Bates
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-02-14 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|