Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: sequel error handeling
spox
5/31/2009 8:41:00 PM
On Sunday 31 May 2009 05:44:54 am jeljer te Wies wrote:
> hee people.
>
> I have a problem with error handeling in sequel.
> here is my code:
>
http://pastie....
>
>
> As you can see i have a method called create.
> in my migration i set the domain to be unique. So i get an error when i
> try to set a domain name twice ...
>
> but how can i get that error ? .. i tried (as you can see):
> if item.save
> return true .... etc ..
>
> but that doesn't work :( ( obviously) ...
> i googled, read the cheatsheet, readme etc etc.
> irc doesn't respond so .. hopefully you guys know!!...
>
> thanxs :D
You'll probably get better responses from the sequel list:
http://groups.google.com/group/s...
However, I'm not exactly sure why you define a create method when it is already
provided for you through Sequel::Model.
w = Website.new(:domain => 'somedomain.com')
This will generate an exception if somedomain.com already exists. If you just
want that model, whether it has been created previously or not,
w = Website.find_or_create(:name => 'somedomain.com')
The methods relating to this you are probably looking for are here:
http://sequel.rubyforge.org/rdoc/classes/Sequel/Model/InstanceMe...
Hope that helps.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: sequel error handeling
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password