This file contains hidden or 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
| def show | |
| @category ||= Category.find(params[:id]) | |
| end |
This file contains hidden or 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
| def index | |
| @category = Category.find(:all) | |
| @cat = Category.new | |
| respond_to do |format| | |
| format.html | |
| format.xml { render :xml => @category } | |
| format.json { render :json => @category } | |
| end | |
| end | |
This file contains hidden or 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
| def destroy | |
| if Category.destroy(params[:id]) | |
| flash[:notice] = 'Category successfully deleted !' | |
| redirect_to :action => "index" | |
| else | |
| flash[:error] = 'There was an error processing your request' | |
| redirect_to :action => "index" | |
| end | |
| end |
This file contains hidden or 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
| # Username or email login for restful_authentication in user.rb model | |
| def self.authenticate(login, password) | |
| return nil if login.blank? || password.blank? | |
| u = find_in_state :first, :active, :conditions => ["email = ? OR login = ?",login,login] # need to get the salt | |
| u && u.authenticated?(password) ? u : nil | |
| end | |
This file contains hidden or 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
| def create | |
| user = User.find_by_login(current_user.login) | |
| @category = Category.new(params[:category]) | |
| if user.categories.create params[:category] | |
| flash[:notice] = 'Category successfully added !' | |
| redirect_to(categories_url) | |
| else | |
| flash[:notice] = 'There was an error processing your request' | |
| redirect_to(categories_url) | |
| end |
This file contains hidden or 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
| # run by doing: | |
| # rake locales:compile LANG_TARGET=pt-BR | |
| namespace :locales do | |
| desc "Compare locale files and get differences and missing keys" | |
| task :compile do | |
| ENV['LANG_SOURCE'] = 'en' if ENV['LANG_SOURCE'].nil? | |
| if ENV['LANG_TARGET'].nil? | |
| puts "define the target language using the LANG_TARGET environment variable\nrake locales:compile LANG_TARGET=pt-BR" | |
| exit(1) | |
| end |
This file contains hidden or 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
| task :create_db do | |
| ruby "migrate.rb" | |
| end |
This file contains hidden or 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 | |
| belongs_to :user | |
| has_many :bills | |
| has_many :expenses | |
| validates_presence_of :name, :message => "You didn't provide account name" | |
| validates_length_of :name, :minimum => 4, | |
| :message => "Account name must be 4 characters minimum", | |
| :on => :create |
This file contains hidden or 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
| #] results_per_page=15 since_id=0 total=1>, @query={:q=>["httparty", "from:jnunemaker"]}> |