Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32cc26b
commit 6173321
Showing
7 changed files
with
63 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
A custom template generator | |||
=========================== | |||
|
|||
rails3 template for customizing generators | |||
|
|||
Nested scaffold | |||
=========================== | |||
rails g nested_scaffold ParentModel:ChildModel properties_hash | |||
|
|||
Example: | |||
rails g nested_scaffold Blog:Comment title:string body:text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
Description: | |||
This generates message partials for displaying messages/notifications | |||
|
|||
Example: | |||
rails generate messages | |||
|
|||
This will create: | |||
app/views/shared/_errors.erb.html | |||
app/views/shared/_notifications.erb.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,16 @@ | |||
class MessagesGenerator < Rails::Generators::Base | |||
source_root File.expand_path('../templates', __FILE__) | |||
|
|||
def copy_view_files | |||
available_views.each do |view| | |||
filename = "#{view}.html.erb" | |||
template "erb/#{filename}", File.join("app/views/shared", filename) | |||
end | |||
end | |||
|
|||
private | |||
def available_views | |||
%w(_errors _notifications) | |||
end | |||
|
|||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
<div class="alert-error alert"> | |||
<a class="close" href="#">×</a> | |||
<h2><%%= t(:error_msg_title) %></h2> | |||
<ul> | |||
<%% model.errors.full_messages.uniq.each do |msg| %> | |||
<li><%%= msg %></li> | |||
<%% end %> | |||
</ul> | |||
</div> |
13 changes: 13 additions & 0 deletions
13
lib/generators/messages/templates/erb/_notifications.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
<div class="alert-notify alert"> | |||
<a class="close" href="#">×</a> | |||
<h2><%%= t(:notification_title) %></h2> | |||
<ul> | |||
<%% if message %> | |||
<li><%%= msg %></li> | |||
<%% else %> | |||
<%% messages.each do |msg| %> | |||
<li><%%= msg %></li> | |||
<%% end %> | |||
<%% end %> | |||
</ul> | |||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters