Hi Guys,
I am trying to get my head around drop down menus and observe_field
(ajax?)
I have :
a ‘job’ model
a vfxshotid model
A job has_many :vfxshotids
A vfxshotid belongs_to :job
I need a page that has 2 drop down menus
The first - list of ‘vfxshotids’ for a job
The second - is a list of directories in a ‘vfxshotid’ directory.
At the moment I don’t know how to pass the arguements around. I followed
this post but i can get it to work, and i wonder if the code is out of
date anyway -
http://www.nabble.com/related-drop-down-list---ajax-td2367869.html
If anyone can give me some advice I’d really appreciate it.
Thanks!
Adam
Here is my code:
VIEW - newvfxasset.html.erb
<% title ‘New Asset’%>
New asset
<%= error_messages_for :asset %>
<% form_for @asset do |f| %>
Select VFX shot id <% for vfxshot in ([email protected]) %> <%= @job.vfxshotids[vfxshot].jobvfxshot_name %> <% end %><%= observe_field(“vfxshotid”, :frequency => 0.25, :update =>
“vfxapp_id_container”, :url => { :action => :get_vfxapps_for_vfxshotid
}, :with => “‘vfxshotid=’+value”) %>
<%= f.submit "Create" %>
<% end %>
<%= link_to ‘Back’, assets_path %>
jobs controller
def newvfxasset
def get_vfxapps_for_vfxshotid
@loggedinuser = session[:user_id]
@assetstartpath = @@jobsrootdirectory + '/' + @job.jobidstring +
‘_’ + @job.client.name + ‘/vfx/’ + vfxshotid + ‘/’ + @loggedinuser.login
print @assetstartpath
# @vfxshotidvfxapps = [Dir.glob(@assetstartpath)]
@vfxshotidvfxpaps = ['a', 'b', 'c', 'd']
end
@job = Job.find(params[:id])
@asset = Asset.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @job }
end
end