So....let's have a look if I understood the issue:
-Find_all_by is actually the same like Find(:all), however Find_all_by
is much shorter and less complicated than the syntax of Find(:all)
-So in my CONTROLLER it says @files = find(:all) however I don't want
to see all files displayed in my selection box, because I only want to
see the foles whose mandant_id is the same like the mandant_id in
invoice.
So i decided to change the @files = find(:all) into => @files =
File.find_all_by_mandant_id(Invoice.mandant_id)
But this doesn´t work so does any one has an inspiration to get it
working??
thnx a lot for the idea, i really apreciate it!!
however it still doesn't work correctly so anyone has an other
suggestion?
well i think it could help to update the mandant_id before carrying on
with the files_id, because if not the how could the database actually
know the
new value for the mandant_id???
--> for this I think u need :onchange => "#{remote_function(:url =>
{:action => "update_sprints"}, :with => "'project_id='+value")}"})
However i cannot really work out how this works....or why the formula
is like this.....
thnx a lot for the idea, i really apreciate it!!
however it still doesn't work correctly so anyone has an other
suggestion?
What do you mean 'it doesn't work'? Did it generate an error? What
it should do is find all the Files with mandant_id of
@invoice.mandant_id. If it did not do this what did it do? If that
is not what you want it to do please try asking the question again in
a different way as it is not clear what you want.
well i think it could help to update the mandant_id before carrying on
with the files_id, because if not the how could the database actually
know the
new value for the mandant_id???
Pardon? This makes no sense to me. Why is there a new value for the
mandant_id when you are trying to find all the Files with a given
mandant_id?
-->one for choosing the mandant_id
--> and then later having tht information in my second selection box i
only want to see the files_id which correspond to tht mandant.....
--> and i will choose one which i will see later in the database next
to the mandant_id
However in the moment i have the to selection boxes and they work fine
ecxept tht the second one does't display ONLY the files corresponding
to the mandant.
Does tht make any sense know??
and surry for the bad understanding....
In that case you may want to use AJAX to update the second selection
box when the user selects from the first one. If you have not used
AJAX with Rails then a bit of googling will provide numerous tutorials
and guides.
thank you sooo much!! tht was just what i needed for my problem!!
however with each solution....there comes a new problem....so maybe
could you please help me??
What I am pretending to do is this:
1) When I create a new invoice the invoice.id should put itself
automatically in the place of the slip.invoice_id
--> for actually finding out in which slip to put the new invoice.id I
applied many find mehods:
@akte = Akte.find_all_by_mandant_id(@rchng.mandant_id)
@slip = Slip.find_all_by_akte_id(@akte, :conditions => {:rchng_id
=> 'NULL'})
--> and i donot get an error message when creating a new invoice...
2) Now tht i have found the right slip to put my invoice.id in I don't
know how to tell ruby on rails that it copies the invoice.id and
pastes it into the slip.invoice_id. However I've tried this:
--> @slip.each do |slip|
slip.rchng_id = rchng.id
end
--> and i don't get an error message however, the invoice.id does not
appear in the slip.invoice_id
So anybody has an idea of how to get this working??
thnx a lot in advance
So you said that the invoice.id must be saved before I can actually
start working with it no??
-->Therefore I should locate my find methods and the loop in the
controller's def creat. Because that would mean that the invoce.id
I've choosen earlier from my selection box has allready been saved,
no??
thank you!
p.s.:the shallow understanding might be because I'm quite new to ruby
on rails ; )
Well found a solution to part of my last problem....
the find methods actually work know =)
#Controller
--> @invoice = Invoice.new
@files = File.find_all_by_mandant_id(@invoice.mandant_id)
@slips = Slip.find(:all, :conditions =>
{:invoice_id=>nil, :file_id=>@files})
However i'm still trying to find out how to OVERWRITE THE BLANK
invoice_id IN MY SLIP CLASS WITH THE @invoice.id.
In the moment my code looks something like this:
#Cotroller
-->@slips.each do |slip|
invoice_id =@invoice.id
end
Although it doesn't create an error message it still doesn't overwrite
the blank Slip.invoice_id......
So if anyone has a suggestion or an idea, please help me
Thanks in advance....