similar to: avoiding exceptions in views

Displaying 20 results from an estimated 10000 matches similar to: "avoiding exceptions in views"

2008 Jul 20
10
STI and fixtures
Hi all ! Loading fixtures doens''t seems to associate my 2 objects, do know what''s wrong ? In app/ class Manager < Employee has_many :employees, :foreign_key => :reports_to end class Employee < Person belongs_to :manager, :foreign_key => ''reports_to'' end class Person < ActiveRecord::Base belongs_to :address end fixtures for
2006 May 20
3
In a find, can''t you use both :include and :limit ?
I''m trying to do a find that includes a join. It has to be a find because I''m using the results for a Pagination, so I need to limit my query to the number of results I want to display per page. Here''s the type of thing I want to do: Employee table <-> Skills_Employees table <-> Skills table Let''s say I want to find all the employees who have
2007 Oct 16
3
Controller iterating through returned records and appending to each
I have a controller that gets a list of employees (which has an "include => [:salaries, :incentives, :billablegoals, :reviews]"). I then need it to iterate through each employee and determine their current active goal based on the "effective date." After playing around with it a bunch, I got the following to work. Only problem is that if I remove the "@employees.each {
2008 Oct 25
2
Update action | NoMethodError | nil.to_sym
Ok, totally no reason why I''m getting an error in this model update and no other. HELP! CONTROLLER: # GET /employees/1/edit def edit @employee = Employees.find(params[:id]) end VIEW: <h1>Edit Employee</h1> <div id="main-sub"> <%= error_messages_for :employees %> <% form_for(@employee) do |f| %> <table width="600"
2008 Jun 22
3
Routing Error No route matches "/employee/list" with {:method=>:get}
hi, I am very frustrated by this error when I just put together a very simple project from one of the textbook on RoR: Routing Error No route matches "/employee/list" with {:method=>:get} For your reference, #The following is EmployeesController.rb class EmployeesController < ApplicationController scaffold :employee # create scaffold code for controller #
2006 Aug 01
2
HOWTO? security based on data values
Hi! I recently started with RoR and this may be a newbie question. I have a company table, employee table and transactions table. 1 company has many employees. Each employee performs many transactions. Employees from different companies LOGIN to the system to record their transactions. Employees can search on all transactions associated to their companies (indirect relationship via employee),
2006 Mar 28
2
Fastest way of adding " " around multiline text in RADRAILS
lets say i have the following SQL in my database editor : When i paste it into rad rails i have to add quotes and the ''+'' symbol to the end of each line. It is very tedious. What is the best method? select timesheets.employee, sum(items.hours) as hours, sum(items.hours*timesheets.cost) as cost, sum(items.hours*timesheets.charge*decode(activities.chargetype,0,1,0)) as charge,
2006 Mar 29
3
partial variable help
Can''t work this out: In list.rhtml: <% for employee in @employees -%> <%= render(:partial => "list_form", :object => employee) %> <% end -%> In _list_form.rhtml (partial): <%= employee.id %> In controller: @employees = Employee.find(:all) I get the following error: undefined local variable or method `employee'' I everything is correct
2006 Mar 28
2
In_place_editor_field throws error ...
I receive the following error: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id when trying to use the in_place_editor_field tag: <% for employee in @employees %> <%= in_place_editor_field :employee, employee.fname %> <% end %> My model is called Employee and is being populated from a controller method employees_list:
2006 Apr 26
2
two layers of has_many
Hi, There are many companies. Each company has many departments. Each department has many employees. The following find_by_sql method seems awful. What is the best way to get all the employees of a company? class Company < ActiveRecord::Base has_many :departments def employees Employee.find_by_sql("SELECT employees.* FROM companies, departments, employees
2009 May 05
9
no sql in the controller guideline
hello. i just checked Chad Fowler''s post "20 Rails Development No-No''s" and one guideline caught my attention. it says: "Nothing that looks at all like SQL should go into a controller, view, or helper." it really came as a surprise to me as Rails itself seems to go against such practice by its AR ''conditions'' option, which most of the times
2007 Jul 26
1
Bi-directional self-referential HABTM
Hi, I''m having a little trouble figuring out how to make a self- referential HABTM bi-directional. I have a Employee class. Each employee can have a couple of bosses, who are also employees. The employee class has the following HABTM: has_and_belongs_to_many :bosses, :class_name => "Employee", :join_table => "bosses_courses", :association_foreign_key =>
2006 Apr 13
7
Whats the best way to achieve this?
employees HABTM projects, projects HABTM employees. I am doing a permissions page for a selected project. I know that I can get all of the employees in the system (@employee.find(:all)) or get all the employees for the selected project. What i''m trying to do is get a list of all the employees in the system and have a check box that states if they are associated with the current
2005 Oct 10
1
Need help with hint and call group
We have 4 employees and we're running Cisco 7970 phones. Each phone has a unique SCCP line configured (in the autologin area of the sccp.conf file) for each employee. We have hints set up in the extension.conf file like the following: exten => 101,hint,SCCP/101 exten => 102,hint,SCCP/102 exten => 103,hint,SCCP/103 exten => 104,hint,SCCP/104 We have speeddial= lines set
2006 Mar 12
3
Newbie: using find like a sql join query
I have a working Rails app with several related tables, but can''t find an answer to this question in the Dave Thomas Rails book. Imagine for example: table departments with columns: id, department_name table employees with columns: id, department_id, employee_name and of course the employees table has a constraint foreign key (department_id) references departments(id) So this is
2006 Mar 13
3
validates_associated problem
Hello, I have a situation where an ''employee'' belongs to a ''department'' and have setup the relationship as follows. class Employee < ActiveRecord::Base belongs_to :department, :foregin_key => "department_id" validates_associated :department_id end class Department < ActiveRecord::Base has_many :employees def validate_on_update
2007 Jan 16
2
:include with conditions.
Lets say I have an owner record which has_many employees. If I want to eager load the employees then Owner.find(:all, :include => :employee) works fine and dandy. What if I only wanted to include male employees in the eager loading for instance? Is there an elegant and simple way to eager load with a condition applied to the included model? Have google and API''d around but
2006 Jan 27
2
DB & AR advise please (diagram inc)
Hi, Being new to Rails and Active record could someone please check my database diagram: http://spectrais.com//images/0.png I am building a trouble ticket system for my company. Simply put a client has many users. Those users can create trouble tickets. Each trouble ticket can have many journals that track the progress of the ticket. An employee (of our company) can take ownership of a
2006 Aug 16
2
accessing a model from a migration
Hello again! ok, i have some initial migration code which sets up my apps schema. i have a few tables that get initialized with data in this migration where i have the table data in yaml format in test/fixtures. i use db:fixtures:load FIXTURES=countries,provstates,employees to initialize these tables.. here''s the wrinkle: employees when it gets loaded should only contain the admin
2011 Sep 12
1
Superimposing titles on dotcharts
I've created a chart with times that employees have entered data on named tasks as in the following example: Employee <- c(rep("Tom", 127),? rep("Dick", 121),? rep("Sally", 130) ) Time <- c(seq(as.POSIXct("2011-09-12 07:00:00"), as.POSIXct("2011-09-12 14:00:00"), 200), seq(as.POSIXct("2011-09-12 07:00:00"),