Created
November 30, 2013 14:28
-
-
Save azraai/7719749 to your computer and use it in GitHub Desktop.
Transititions gem errors
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
class UsersController < InheritedResources::Base | |
belongs_to :account | |
actions :all, :except => :destroy | |
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
class Account < ActiveRecord::Base | |
include ActiveModel::Transitions | |
attr_accessible :identifier, :name, :package_id, :user_id, :status | |
has_paper_trail | |
belongs_to :package | |
belongs_to :user | |
has_many :users | |
validates :name, :identifier, :package_id, presence: true | |
validates :identifier, uniqueness: true | |
validates :user_id, presence: true, if: "self.users.present?" | |
state_machine auto_scopes: true, attribute_name: :status do | |
state :active | |
state :inactive | |
event :deactivate do | |
transitions from: :active, to: :inactive | |
end | |
event :activate do | |
transitions from: :inactive, to: :active | |
end | |
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
class User < ActiveRecord::Base | |
include ActiveModel::Transitions | |
ROLES = ['owner', 'manager', 'staff'] | |
attr_accessible :account_id, :email, :name, :password, :password_confirmation, :role, :status | |
has_paper_trail | |
belongs_to :account | |
validates :name, :email, :account_id, :role, presence: true | |
validates :role, inclusion: { in: ROLES } | |
state_machine auto_scopes: true, attribute_name: :status do | |
state :active | |
state :suspended | |
event :suspend do | |
transitions from: :active, to: :suspended | |
end | |
event :activate do | |
transitions from: :suspended, to: :active | |
end | |
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
source 'https://rubygems.org' | |
gem 'rails', '3.2.15' | |
gem 'mysql2' | |
gem 'bcrypt-ruby', '~> 3.0.0' | |
gem 'rails-settings-cached' | |
gem 'inherited_resources' | |
gem 'has_scope' | |
gem 'transitions', :require => ["transitions", "active_model/transitions"] | |
gem 'devise' | |
gem 'cancan' | |
gem 'kaminari' | |
gem 'simple_form' | |
gem 'delayed_job_active_record' | |
gem 'ransack' | |
gem 'daemons' | |
gem 'redcarpet' | |
gem 'wicked_pdf' | |
gem 'paper_trail', '>= 3.0.0.rc2' | |
group :assets do | |
gem 'therubyracer', :platforms => :ruby | |
gem 'sass-rails', '~> 3.2.3' | |
gem 'less-rails' | |
gem 'coffee-rails', '~> 3.2.1' | |
gem 'uglifier', '>= 1.0.3' | |
end | |
gem 'jquery-rails' | |
gem 'jquery-cookie-rails' | |
gem 'less-rails-bootstrap' | |
gem 'kaminari-bootstrap' | |
gem 'select2-rails' | |
gem 'font-awesome-rails' | |
gem 'bootstrap-datepicker-rails' | |
gem 'humane-rails' |
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
<div class="panel"> | |
<%= simple_form_for @user do |f| %> | |
<div class="panel-body"> | |
<%= f.input :name %> | |
</div> | |
<div class="panel-footer"> | |
<div class="form-group m-b-none"> | |
<div class="col-sm-offset-2 col-sm-10"> | |
<%= f.submit :class => 'btn btn-success' %> | |
<%= link_to t('buttons.cancel'), @user.persisted? ? account_user_path : account_users_path, :class => 'btn btn-default' %> | |
</div> | |
</div> | |
</div> | |
<% end %> | |
</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
<div class="header bg-white-only b-b"> | |
<h4 class="pull-left"><%= t '.title' %></h4> | |
<div class="btn-group pull-right"> | |
<%= link_to t('buttons.accounts.view'), account_path(@account), :class => 'btn btn-success btn-sm' %> | |
<%= link_to t('buttons.users.all'), account_users_path(@account), :class => 'btn btn-success btn-sm' %> | |
</div> | |
<div class="clearfix"></div> | |
</div> | |
<div class="wrapper"> | |
<%= render 'form' %> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment