#apache #archlinux #asterisk #centos #debian #gentoo #haskell #kde #kubuntu #lisp #math #mysql #perl #python #ruby-lang #rubyonrails #suse #ubuntu #vim #wikipedia 0 1 2 3 4 5 6 7 8 9 10 11
Top Prev 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 Next
#rubyonrails
<victori> curl !
<|PiP|> if i want to validate that a customer's referrer is a real customer, how can i do it?
<|PiP|> and how can i get the form to take the referrer's username instead of it's id
<pstickne> take the username. look up the id.
<pstickne> if there is no matching username, they don't exist.
<|PiP|> pstickne: but i want it to return that the given referrer is invalid
<pstickne> but that just provides balancing, they could still be lying about who "they" are.
<pstickne> well, make it do that
<|PiP|> ive tried and im not sure how to
<|PiP|> ive made a attr_accessor :referrer_username
<|PiP|> that my form can fill with the username
<pstickne> @ref = User.find_by_name(...); <%= "Bad referrer" unless @ref %>
<pstickne> do you need it part of a model? (does it belong?)
<pstickne> it may be appropriate to keep the field isolated from direct model manipulation
<|PiP|> well i want to be able to make a referral by using the Model
<|PiP|> without using the ID
<|PiP|> i want it to try to set referrer to Customer.find_by_username(referrer_username) iff referrer_username is set
<|PiP|> and if it can't find, then raise a validation error
<zachinglis> Guys, I have: <option ... value="[1,3]" ... How do I split the option up into 2 values on the other side (var1,var2 = doesn't work.
<arooni> anyone using restful authentication?
<arooni> is it better to do.... model.save! (and rescue) or model.save; if model # process as noarmal end; #now process error case
<pstickne> zachinglis, you need to uhm, parse it. it looks like it's YAML-compliant, so try to use YAML
<|PiP|> pstickne: do you know how to solve my problem?
<|PiP|> should i set it in the before_create ?
<zachinglis> pstickne: There is a way that I can't remember for the life of me to just use [1,3], and then var1=,var2=..... but elaborate on your YAML idea
<pstickne> |PiP|, I don't understand why it gets to the model...
<|PiP|> pstickne: I want to be able to create a referrer easily
<|PiP|> and do it using a model's method
<pstickne> then maybe make a referrer_name= that will take a username and turn it into the correct relationship
<saint_cypher> arooni, I don't consider users entering crappy data an exceptional case so I use .save
<arooni> hehe
<arooni> saint_cypher: so you use the.... if model.save; #proceed as normal; end; #now handle error case
<arooni> approach?
<saint_cypher> arooni, yeah like that, or you can check the model.errors to see as well
<pstickne> zachinglis, I don't know how to configure YAML to read that; you could split it by hand easily enough;
<arooni> saint_cypher: something like.... unless model.errors; #proceed as normal; end; #now handle error case ?
<zachinglis> pstickne: elaborate?
<pstickne> "[1,2,3]".scan(/\d+/).map {|i| i.to_i}
<pstickne> I think RoR supports ".map &:to_i" or something crazy
<saint_cypher> arooni, if model.errors.length > 0; flash[:errors] = model.errors; render :something; else render :something_else; end
<pstickne> saint_cypher, not a fan of errors_for?
<saint_cypher> pstickne, never used it, will look into...
<pstickne> (also, m.valid? <=> m.errors.size == 0)
<pstickne> err, read <=> as the double-headed implies
<victori> hmm well AR is fscked for me
<pstickne> oh, no!
<pstickne> you should talk to it nicely
<victori> User.find(:all,:include=>:blogs, :distinct=>:user.id,:limit=>10,:order=>'blogs.created_at desc',:conditions=>'display = true and blogs.user_id is not null and blogs.user_id != 2') it isn't retrieving properly
<victori> sort is completely wrong
<pstickne> check the sql.
Previous Page Next Page