Skip to content

Instantly share code, notes, and snippets.

View Frank004's full-sized avatar

francisco Quinones Frank004

  • HB Quality Ware
  • Puerto Rico
View GitHub Profile
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,:authentication_keys => [:login]
has_one :client_user
has_one :service_user
end
class ClientUser < ActiveRecord::Base
belongs_to :user, :dependent => :destroy
Project.order("RANDOM()").limit(rand(1..4)).select(:id)
Project Load (1.0ms) SELECT "projects"."id" FROM "projects" ORDER BY RANDOM() LIMIT 2
=> #<ActiveRecord::Relation [#<Project id: 12>, #<Project id: 7>]>
irb(main):002:0> Project.order("RANDOM()").limit(rand(1..4)).select(:id)
Project Load (0.5ms) SELECT "projects"."id" FROM "projects" ORDER BY RANDOM() LIMIT 2
=> #<ActiveRecord::Relation [#<Project id: 12>, #<Project id: 7>]>
irb(main):003:0> Project.order("RANDOM()").limit(rand(1..4)).select(:id)
Project Load (0.5ms) SELECT "projects"."id" FROM "projects" ORDER BY RANDOM() LIMIT 4
=> #<ActiveRecord::Relation [#<Project id: 4>, #<Project id: 8>, #<Project id: 39>, #<Project id: 1>]>
irb(main):004:0> Project.order("RANDOM()").limit(rand(1..4)).select(:id)
rake db:populate --trace
** Invoke db:populate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:populate
#<Company:0x007fbff83e3ae0>
#<Project:0x007fbff6eee4c8>
#<ProjectDetail:0x007fbff4091ee0>
#<User:0x007fbffe4ca6d8>
rake aborted!
source 'https://rubygems.org'
ruby '2.2.0'
gem 'rails', '4.2.1'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jquery-turbolinks'
gem 'jbuilder', '~> 2.0'
En el article block pones una de estas
<%= link_to article.user.name, user_path(article.user_id) %>
or
<%= link_to article.user.name, user_path(article.user.id) %>
@users = User.all
@user.each do |u|
u.name
u.tasks do |t| <---------- I like to do check where task start_date is in a range of date
t.name
end
end
[
{
name: "Group 1"
data: [1,2,3,4]
},
{
name: "Group 2"
data: [1,2,3,4]
}
]
f.select(:est_hrs, options_for_select('00'..'24'), {}, {class: 'form-control'})
class ApplicationController < ActionController::Base
before_filter :authenticate_user!
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
def after_sign_out_path_for(resource_or_scope)
new_user_session_path
end
#esto lo tengo porque tengo 2 tipos de user que quiero redirigir cuando inicien la sección.
def show
@accidents = @employee.accidents.paginate(:page => params[:accidents], :per_page => 5)
@incidents = @employee.incidents.paginate(:page => params[:incidents], :per_page => 5)
@trainings = @employee.trainings.paginate(:page => params[:trainings], :per_page => 5)
end