search for: folder_id

Displaying 7 results from an estimated 7 matches for "folder_id".

2006 May 18
3
access to an ApplicationController property from a view
Hi there, How is it possible to get access to an ApplicationController property from a view? Consider this (simplified) situation: class ApplicationController < ActionController::Base def folder_id @folder_id = params[:id] return @folder_id end end class FolderController < ApplicationController def show @folder = Folder.find_by_id(folder_id) end end So far, so good, BUT... when trying to access folder_id in the show-view like this <%= folder_id %>, I get an...
2008 Apr 18
3
Relating to records in same table
I''m in progress of making a little folder system with Ruby on Rails. I''ve got a "folders" table. Each "folder" has got an id and a folder_id. The folder_id is supposed to represent the folders'' parent folder. How can I tell Rails? I would like Rails to automaticly delete all subfolders of a folder when I delete the folder it self. Any ideas? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~---...
2006 Jan 11
3
Just update 1 field
Hi All, I wonder how I can get rails to update just one field when I do Myfile.save. Right now this happens when I do a Myfile.save: UPDATE myfiles SET `folder_id` = 0, `filesize` = 1, `data` = ''2f7573722f6c6f63616c2f6d ... f7061636b65743d33324d'', `user_id` = 0, `date_modified` = ''2006-01-11T23:33:57+0100'', `filename` = ''mysqlscripts.sql'' WHERE id = 4 but when just the filename has changed I''...
2006 Aug 17
1
How to sort child table on fields in the associated parent
For an Xray file system patients have folders and folders have studies. That is: patients folders studies id id id name patient_id folder_id ... label type ... ... The list of studies with their associated folder and patient might look like this: name folder_label study_type Brown,Sam brsa1 CXR Jones,Gary jg99999 CXR Jones,Gary joga15...
2005 Oct 23
12
Showing a neat error message
Hi All, I''m trying to prevent users from deleting a folder that has contents like this: class Folder < ActiveRecord::Base has_many :myfiles has_many :folders belongs_to :folder validates_uniqueness_of :name, :scope => "folder_id" before_destroy :dont_destroy_folder_with_contents def dont_destroy_folder_with_contents if Folder.find(id) != nil || Myfile.find(id) != nil raise "Cannot delete this folder because it has contents" end end end This works fine: the folder''s not deleted....
2006 Mar 10
1
Validate fields and display errors from two models?
Hi, I have here a problem I''ve been working at for a little while but I can''t seem to get the error messages to appear correctly. My form looks something like this for "ModelA": [errors_for "modelA"] [form for "modelA"] [text "modelA" "fieldname1"] [text "modelB" "fieldname2"] [submit] [/form] The reason
2006 Mar 13
6
:dependent => :destroy
...g I don''t understand about :dependent => :destroy. I hope someone can help me. Consider this code: class Folder < ActiveRecord::Base has_many :myfiles has_many :folders has_many :group_folders, :dependent => :destroy validates_uniqueness_of :name, :scope => "folder_id" validates_presence_of :name before_destroy :dont_destroy_folder_with_contents # Folders containing files or sub-folders # can not be deleted def dont_destroy_folder_with_contents if self.folders.length > 0 or self.myfiles.length > 0 raise "Can''t...