Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Hash sytax fix.

  • Loading branch information...
commit d198b64f790ec4ad04bc79b0c1899fc55bf7200a 1 parent e732c9e
@lisovskyvlad authored
View
2  Gemfile
@@ -20,6 +20,8 @@ gem 'bson_ext'
gem 'haml'
gem 'simple_form'
+gem 'syntax_fix'
+
group :development do
gem 'rails3-generators', :git => 'https://github.com/neocoin/rails3-generators.git'
gem 'quiet_assets'
View
2  Gemfile.lock
@@ -217,6 +217,7 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
+ syntax_fix (0.0.2)
therubyracer (0.10.1)
libv8 (~> 3.3.10)
thin (1.3.1)
@@ -265,6 +266,7 @@ DEPENDENCIES
rspec-rails
sass-rails (~> 3.2.3)
simple_form
+ syntax_fix
therubyracer
thin
twitter-bootstrap-rails
View
4 app/views/posts/edit.html.haml
@@ -1,4 +1,4 @@
- model_class = @post.class
.page-header
- %h1=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human, :default => "Edit #{model_class.model_name.human}")
-= render :partial => "form"
+ %h1=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human, :default => 'Edit #{model_class.model_name.human}')
+= render :partial => 'form'
View
20 app/views/posts/index.html.haml
@@ -1,19 +1,11 @@
- model_class = Post.new.class
.page-header
%h1=t '.title', :default => model_class.model_name.human.pluralize
-%table.table.table-striped
- %thead
- %tr
- %th= model_class.human_attribute_name(:title)
- %th= model_class.human_attribute_name(:content)
- %th=t '.actions', :default => t('helpers.actions')
- %tbody
- - @posts.each do |post|
- %tr
- %td= link_to post.title, post_path(post)
- %td= post.content
- %td
- = link_to t('.edit', :default => t('helpers.links.edit')), edit_post_path(post), :class => 'btn btn-mini'
- = link_to t('.destroy', :default => t('helpers.links.destroy')), post_path(post), :method => :delete, :data => { :confirm => t('.confirm', :default => t('helpers.links.confirm', :default => 'Are you sure?'))} , :class => 'btn btn-mini btn-danger'
+
+ - @posts.each do |post|
+ = link_to post.title, post_path(post)
+ = post.content
+ = link_to t('.edit', :default => t('helpers.links.edit')), edit_post_path(post), class: 'btn btn-mini'
+ = link_to t('.destroy', :default => t('helpers.links.destroy')), post_path(post), method: :delete, data: { confirm: 'Are you sure?'} , class: 'btn btn-mini btn-danger'
= link_to t('.new', :default => t('helpers.links.new')), new_post_path, :class => 'btn btn-primary'
View
5 app/views/posts/new.html.haml
@@ -1,4 +1,3 @@
-- model_class = @post.class
.page-header
- %h1=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human, :default => "New #{model_class.model_name.human}")
-= render :partial => 'form'
+ %h1 Новый пост
+= render partial: 'form'
View
6 app/views/posts/show.html.haml
@@ -12,6 +12,6 @@
= @post.content
.form-actions
- = link_to t('.back', :default => t("helpers.links.back")), posts_path, :class => 'btn'
- = link_to t('.edit', :default => t("helpers.links.edit")), edit_post_path(@post), :class => 'btn'
- = link_to t('.destroy', :default => t("helpers.links.destroy")), post_path(@post), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
+ = link_to t('.back', default: t('helpers.links.back')), posts_path, class: 'btn'
+ = link_to t('.edit', default: t('helpers.links.edit')), edit_post_path(@post), class: 'btn'
+ = link_to t('.destroy', default: t('helpers.links.destroy')), post_path(@post), method: 'delete', data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
View
2  config/application.rb
@@ -10,7 +10,7 @@
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
- Bundler.require(*Rails.groups(:assets => %w(development test)))
+ Bundler.require(*Rails.groups(assets: %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
View
42 config/initializers/simple_form.rb
@@ -5,8 +5,8 @@
# wrapper, change the order or even add your own to the
# stack. The options given below are used to wrap the
# whole input.
- config.wrappers :default, :class => :input,
- :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
+ config.wrappers :default, class: :input,
+ hint_class: :field_with_hint, error_class: :field_with_errors do |b|
## Extensions enabled by default
# Any of these extensions can be disabled for a
# given input by passing: `f.input EXTENSION_NAME => false`.
@@ -18,7 +18,7 @@
b.use :html5
# Calculates placeholders automatically from I18n
- # You can also pass a string as f.input :placeholder => "Placeholder"
+ # You can also pass a string as f.input placeholder: "Placeholder"
b.use :placeholder
## Optional extensions
@@ -41,44 +41,44 @@
## Inputs
b.use :label_input
- b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
- b.use :error, :wrap_with => { :tag => :span, :class => :error }
+ b.use :hint, wrap_with: { tag: :span, class: :hint }
+ b.use :error, wrap_with: { tag: :span, class: :error }
end
- config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
+ config.wrappers :bootstrap, tag: 'div', class: 'control-group', error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
- b.wrapper :tag => 'div', :class => 'controls' do |ba|
+ b.wrapper tag: 'div', class: 'controls' do |ba|
ba.use :input
- ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
- ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
- config.wrappers :prepend, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
+ config.wrappers :prepend, tag: 'div', class: "control-group", error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
- b.wrapper :tag => 'div', :class => 'controls' do |input|
- input.wrapper :tag => 'div', :class => 'input-prepend' do |prepend|
+ b.wrapper tag: 'div', class: 'controls' do |input|
+ input.wrapper tag: 'div', class: 'input-prepend' do |prepend|
prepend.use :input
end
- input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
- input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
+ input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
+ input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
end
end
- config.wrappers :append, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
+ config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
- b.wrapper :tag => 'div', :class => 'controls' do |input|
- input.wrapper :tag => 'div', :class => 'input-append' do |append|
+ b.wrapper tag: 'div', class: 'controls' do |input|
+ input.wrapper tag: 'div', class: 'input-append' do |append|
append.use :input
end
- input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
- input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
+ input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
+ input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
end
end
@@ -90,8 +90,8 @@
# Define the way to render check boxes / radio buttons with labels.
# Defaults to :nested for bootstrap config.
- # :inline => input + label
- # :nested => label > input
+ # inline: input + label
+ # nested: label > input
config.boolean_style = :nested
# Default class for buttons
View
2  config/routes.rb
@@ -1,4 +1,4 @@
Blog::Application.routes.draw do
resources :posts
- root :to => 'posts#index'
+ root to: 'posts#index'
end
View
28 spec/controllers/posts_controller_spec.rb
@@ -45,7 +45,7 @@ def valid_session
describe "GET show" do
it "assigns the requested post as @post" do
post = Post.create! valid_attributes
- get :show, {:id => post.to_param}, valid_session
+ get :show, {id: post.to_param}, valid_session
assigns(:post).should eq(post)
end
end
@@ -60,7 +60,7 @@ def valid_session
describe "GET edit" do
it "assigns the requested post as @post" do
post = Post.create! valid_attributes
- get :edit, {:id => post.to_param}, valid_session
+ get :edit, {id: post.to_param}, valid_session
assigns(:post).should eq(post)
end
end
@@ -69,18 +69,18 @@ def valid_session
describe "with valid params" do
it "creates a new Post" do
expect {
- post :create, {:post => valid_attributes}, valid_session
+ post :create, {post: valid_attributes}, valid_session
}.to change(Post, :count).by(1)
end
it "assigns a newly created post as @post" do
- post :create, {:post => valid_attributes}, valid_session
+ post :create, {post: valid_attributes}, valid_session
assigns(:post).should be_a(Post)
assigns(:post).should be_persisted
end
it "redirects to the created post" do
- post :create, {:post => valid_attributes}, valid_session
+ post :create, {post: valid_attributes}, valid_session
response.should redirect_to(Post.last)
end
end
@@ -89,14 +89,14 @@ def valid_session
it "assigns a newly created but unsaved post as @post" do
# Trigger the behavior that occurs when invalid params are submitted
Post.any_instance.stub(:save).and_return(false)
- post :create, {:post => {}}, valid_session
+ post :create, {post: {}}, valid_session
assigns(:post).should be_a_new(Post)
end
it "re-renders the 'new' template" do
# Trigger the behavior that occurs when invalid params are submitted
Post.any_instance.stub(:save).and_return(false)
- post :create, {:post => {}}, valid_session
+ post :create, {post: {}}, valid_session
response.should render_template("new")
end
end
@@ -111,18 +111,18 @@ def valid_session
# receives the :update_attributes message with whatever params are
# submitted in the request.
Post.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
- put :update, {:id => post.to_param, :post => {'these' => 'params'}}, valid_session
+ put :update, {id: post.to_param, post: {'these' => 'params'}}, valid_session
end
it "assigns the requested post as @post" do
post = Post.create! valid_attributes
- put :update, {:id => post.to_param, :post => valid_attributes}, valid_session
+ put :update, {id: post.to_param, post: valid_attributes}, valid_session
assigns(:post).should eq(post)
end
it "redirects to the post" do
post = Post.create! valid_attributes
- put :update, {:id => post.to_param, :post => valid_attributes}, valid_session
+ put :update, {id: post.to_param, post: valid_attributes}, valid_session
response.should redirect_to(post)
end
end
@@ -132,7 +132,7 @@ def valid_session
post = Post.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Post.any_instance.stub(:save).and_return(false)
- put :update, {:id => post.to_param, :post => {}}, valid_session
+ put :update, {id: post.to_param, post: {}}, valid_session
assigns(:post).should eq(post)
end
@@ -140,7 +140,7 @@ def valid_session
post = Post.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Post.any_instance.stub(:save).and_return(false)
- put :update, {:id => post.to_param, :post => {}}, valid_session
+ put :update, {id: post.to_param, post: {}}, valid_session
response.should render_template("edit")
end
end
@@ -150,13 +150,13 @@ def valid_session
it "destroys the requested post" do
post = Post.create! valid_attributes
expect {
- delete :destroy, {:id => post.to_param}, valid_session
+ delete :destroy, {id: post.to_param}, valid_session
}.to change(Post, :count).by(-1)
end
it "redirects to the posts list" do
post = Post.create! valid_attributes
- delete :destroy, {:id => post.to_param}, valid_session
+ delete :destroy, {id: post.to_param}, valid_session
response.should redirect_to(posts_url)
end
end
View
8 spec/routing/posts_routing_spec.rb
@@ -12,11 +12,11 @@
end
it "routes to #show" do
- get("/posts/1").should route_to("posts#show", :id => "1")
+ get("/posts/1").should route_to("posts#show", id: "1")
end
it "routes to #edit" do
- get("/posts/1/edit").should route_to("posts#edit", :id => "1")
+ get("/posts/1/edit").should route_to("posts#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@
end
it "routes to #update" do
- put("/posts/1").should route_to("posts#update", :id => "1")
+ put("/posts/1").should route_to("posts#update", id: "1")
end
it "routes to #destroy" do
- delete("/posts/1").should route_to("posts#destroy", :id => "1")
+ delete("/posts/1").should route_to("posts#destroy", id: "1")
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.