Displaying 6 results from an estimated 6 matches for "edit_project".
2006 Jul 03
0
Multiple File Upload
...uploaded
belong to a project):
project_controller.rb:
----------------------
def upload_attachment
project = Project.find(@params[:id])
begin
project.attachments.create(params[:attachment])
rescue
flash[:attachment_error] = "Error at Upload"
end
redirect_to :action => "edit_project", :id => project
end
attachment_model:
-----------------
def attachment=(attachment_field)
self.name = base_part_of(attachment_field.original_filename)
self.content_type = attachment_field.content_type.chomp
self.data = attachment_field.read
end
def base_part_of file_name
name = File....
2006 Jan 08
4
ID from child table not handled by AR
...ere t1.id =
t2.company_id order by t1.name'')
## Showing a nice dropdown list with "Company - Fname Lname"
## Thanx to Chris Hall
@contacts_list = @contacts_list.collect { |c| [ c.name + " - " + c.firstname
+ " " + c.lastname ] }
render_action ''edit_project''
end
def create_project
@project = Project.new(@params[''project''])
@project_contact = ProjectContact.new(@params[''id''])
@project.project_contact = @project_contact
#@project.project_contact.save
if @project.save
flash[:notice] = ''Projec...
2006 Mar 22
1
HABTM / Dropdown Help Needed
I''m terribly new to Rails, so bear with me.
I have an application I am working on which deals with projects and
subcontractors. There can be several subs on each project and each sub
can work on several projects. I have my join table set up and
has_and_belongs_to_many in both models. If I manually put data in the
join table, this works in my show view:
<% for subcontractor in
2006 Jan 09
2
catch id from form and copy between objects
Hi all,
Not completely sure what I''m doing, but I need to get data from another table
based on and id. Below is some breakpointer output:
irb> @params
=> {"project"=>{"project_description"=>"point2", "project_name"=>"break2"},
"action"=>"create_project",
2006 Jan 06
2
IRB hex values
...select t1.name, t2.firstname,
t2.lastname, t2.id from companies AS t1, contacts AS t2 where t1.id =
t2.company_id order by t1.name'')
@project_contacts = @contacts_list.collect { |c| [ c.name + " - " +
c.firstname + " " + c.lastname, c.id ] }
render_action ''edit_project''
-- Models:
class Project < ActiveRecord::Base
has_one :project_contact
has_many :project_products
end
class ProjectContact < ActiveRecord::Base
belongs_to :project
end
class ProjectProduct < ActiveRecord::Base
belongs_to :project
end
--
"Who cares if it doesn''...
2006 Jan 10
15
KISS and DRY? Not even close!
...= contact.first_name
@project.project_contact.last_name = contact.last_name
if @project.save
flash[:notice] = ''Project was successfully created.''
redirect_to :action => ''show_project'', :id => @project.id
else
render :action => ''edit_project''
end
end
Should I have a clean go. Or shape up, go at it and simply continue?
Regards,
Gerard.
P.S. Thanks a lot for your time if you made it al the way down here!!
--
"Who cares if it doesn''t do anything? It was made with our new
Triple-Iso-Bifurcated-Krypton-Gate...