similar to: Question on application/database design for a application port to rails

Displaying 20 results from an estimated 14000 matches similar to: "Question on application/database design for a application port to rails"

2006 Mar 02
3
Modifying "Find" to always add a condition?
I''d like to always add a condition to any version of "find" (e.g. Thing.find(), Thing.find_by_name(), Thing.find_by_whatever) so that in addition to whatever conditions are set, an additional condition is set :conditions=>"user_id=#{current_user.id}" I''d like to make sure that a user only sees/edits/creates entries in the database that have the user_id
2006 Jul 14
5
Acts_As_Taggable Plugin multiple controllers.
I have Acts_As_Taggable Plugin working. I have a HR controller and a sales controller. I have a document in hr tagged whitepaper and a differnent document in sales tagged whitepaper when I am in hr I see the hr document tagged with whitepaper and not the sale document (what I want). but if I click on the tag whitepaper I return two documents, hr and sales. I just want to return the hr document
2006 Mar 03
2
Through relationship
I am working on streamlining one of my apps, and trying to wrap my hands around through, polymorphic, and with_scope. All of these i know i need for what i want to do, based on the little documentation I have found. With this in mid I have tried to implement a simple through in the app to try and get my head around it. This is what I have: class Product < ActiveRecord::Base
2006 Jan 11
3
How do you do a custom sql call in rails?
Hi. I am developing an industry specific crm that allows busineses to track customers in a particular way. Each customer will be assigned a customer number. The first customer will have a customer number of 1, the second customer_number = 2, etc... Note that this customer number is not global but particular to the account that created the customer (see schema snip below). I need to have a
2010 Dec 02
8
CanCan issue when being very specific
So I got CanCan and Devise working well. I have two types of users: Admins and Nonadmins. Admins can edit all of Nonadmins profiles. The problem is, every user (either Admin or Nonadmin) belongs to an Account or Organization. Admins should only be able to edit users from their own Account or Organization. I was able to do that too. The problem is, I can''t display the Create New User
2006 Jul 19
2
Creating a safe sequence generator
Hi all, I''ve got a rails and database question. Accounts have jobs, and job numbers should be assigned per account. Account 89 should have jobs 1-whatever, which are not the same as account 67, which has jobs 1-whatever. In the past, I have accomplished this quite easily with: create table job ( accountid int(10) unsigned not null default 0, jobid int(10) unsigned not null
2006 Jun 29
3
methods to synchronize tdb files between hosts
I use winbind+AD for single sign-on to many Linux machines, and the Linux hosts automount home directories on one Linux file server. I am faced with a need to synchronize the *.tdb files on the file server with all the Linux machines for consistent UID-to-loginID mapping. Has this been tried by sharing the /var/lib/samba/ over nfs with the other servers? Are there any pitfalls? Has this been
2010 Jan 27
1
around_filter and with_scope
i got two controller (with restful actions) where my code is quite ugly and not very dry. every action looks quite like this: if @logged_user.has_role?("admin") User.find(params[:id) else @logged_user.group.user.find(params[:id]) this is a security check that enforce a simple spec: normal user should read/write information only about their group''s users, but
2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
In console, I am trying to create a User but the :account_id does not come in. Console just gives me back :account_id => nil. Obviously I''m trying to set it though. Silly console... But, I can set the account_id column in my controller like so: @user = User.new(params[:user]) @user.account_id = account.id @user.save Here''s what I give to the controller: User.create :name
2006 Jun 19
3
Using set_primary_key breaks acts_as_tree with non-integer column
I just switched from using the standard "id" column into using my own primary key and generating my own unique id for each record. But, this breaks acts_as_tree. Because my new primary key is not an integer, it breaks the SQL query as follows: StatementInvalid in PagesController#create --------------------------------------------------------------------------------------
2006 Nov 01
17
So how can I rewrite my app without using with_scope?
So, I hear that with_scope is going to be deprecated. Which is a bit of a shame, given the stuff I''ve been writing recently. I have a CMS with multiple clients. A ''client'' is essentially a company, with multiple users. Content on the site belongs to a client - content could be messages, images, schedules, etc etc. People belonging to one client should not be able
2006 Jul 27
2
Creating multiple objects from form data
I''m in the process of creating a sign up form for an online application. The form collects account info, company info, and then info for an administrative user. The method looks like this: def create @account = Account.create!(params[:account]) @company = @account.companies.create!(params[:company]) @user = @company.users.create!(params[:user]) end However, this inevitably fails
2007 Oct 18
9
with_scope issue
I have the following code: class User < ActiveRecord::Base has_many :requests do def find_active(options = {}) with_scope :find => { :conditions => ["requests.active = ?", true] } do find(:all, options) end end end end Executing user.requests.find_active results in the following SQL: SELECT * FROM requests WHERE (( requests.user_id = 10 ) AND (
2008 Nov 12
5
dynamic condition for has_one and eager loading issue
Hi, I ve defined the following relation in one of my models with a dynamic where condition: has_one :selection, :foreign_key => ''object_id'', :conditions => ''selection_type = 1 and account_id = # {self.send(:account_id)}'' That works perfect, however when I try to eager load that relation I am getting the following error when doing a
2009 Nov 27
2
update_attribute does not update
My server is running Rails 2.3.4...am I not doing this correctly or is something borked? >> c=Contact.last => #<Contact id: 24, name: "Larry", email: "larry-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", phone: 2147483647, account_id: 8, created_at: "2009-11-27 18:16:25", updated_at: "2009-11-27 18:40:08", hide_name: false, hide_phone: false,
2006 Apr 01
1
STI with_scope on parent - bug or feature?
Hi, It seems that setting a with_scope on the parent class doesn''t do anything MyClass.with_scope(:find=>{:conditions=> ["somecol = ?", ''val'']}) do @ext_pages, @ext_rows = paginate :my_extended_class, { :per_page => 13 } end # this doesn''t generate WHERE somecol=''val'' In order for scope to work you have to call
2006 Jan 19
4
A simple scaffolding question
All, When I generate scaffolding on my model, it doesn''t display all the fields in the create and edit views. It populates the views with text/char and date types, but omits any integer fields. Is this normal behavior or a bug? Thanks! -Nick
2007 Aug 21
3
Eager Loading
is there a way to always eagerly load an associated object so that you don''t have to put :include into every finder? class Product <ActiveRecord::Base belongs_to :user #always load user when product is loaded end Product.find(1).user.login #1 query since user was loaded with the product, same as if i used :include but I don''t want to have to specify it everywhere.
2007 Jul 10
3
No password prompt for ssh from perl script
Hi, I need some help from you guys for one issue I am facing with my script. While logging into localhost using ssh from command prompt it works: It works from command prompt --> ssh loginid at localhost But when we try to login to localhost using ssh from perl script using pseudo terminal, I am getting the following without any password prompt. We are getting following instead of
2006 Sep 08
1
has_many relationship extensions and scoping rules
Hi all ! Is this supposed to work ? class Email < ActiveRecord::Base has_many :to, :class_name => 'Recipient', :conditions => "recipients.source = 'to'" do def create!(*args) with_scope(:create => {:source => 'to'}) do super end end def build(*args) with_scope(:create => {:source => 'to'}) do