[Rails] Re: validation errors bring up stack trace error page

2010-09-01 Thread Ze Ca
new invalid comment. Thanks! Frederick Cheung wrote: > On Sep 1, 12:48�pm, Ze Ca wrote: >> style it in a way that gives off a red warning directly on the page. >> > > typically you do something like > > if Foo.create(params[...]) > #handle success > else > re

[Rails] Re: validation errors bring up stack trace error page

2010-09-01 Thread Ze Ca
is to style it in a way that gives off a red warning directly on the page. Thanks! Colin Law wrote: > On 1 September 2010 03:35, Ze Ca wrote: >> secondly, why can't I style the error? > Can you provide an example of what you mean? If you are getting a > runtime Ruby error th

[Rails] validation errors bring up stack trace error page

2010-08-31 Thread Ze Ca
hello! I made some custom validations for my app, which do catch invalid data in the console. However, when I enter invalid data through a form on the browser view, I get your stack trace error style page (similar to what you see when you get a syntax error or a nil object) instead of the nicely s

[Rails] Re: Re: Re: how to make unique ids for URLs

2010-08-28 Thread Ze Ca
Awesome, thanks Hassan for pointing me in the right direction. Hassan Schroeder wrote: > On Sat, Aug 28, 2010 at 7:30 AM, Ze Ca wrote: >> That is true... I guess what I'm trying to get at is avoid using the >> built in ids as the resource identifier... and instead just

[Rails] Re: Re: how to make unique ids for URLs

2010-08-28 Thread Ze Ca
5:14 AM, Ze Ca wrote: >> I suppose they could, but I'd like to make the URL path as short as >> possible. > > Why? What possible value does an obfuscated and shortened URL > offer anyone? > > If anything, most users would get more value out of something like >

[Rails] Re: how to make unique ids for URLs

2010-08-28 Thread Ze Ca
I suppose they could, but I'd like to make the URL path as short as possible. Plus, it's a excuse to learn how it works :). Colin Law wrote: > On 28 August 2010 05:07, Ze Ca wrote: >> www.myrailsapp.com/1djs34 (or some join of randomly generated letters >> and numb

[Rails] how to make unique ids for URLs

2010-08-27 Thread Ze Ca
The path I currently have for a record in the post table is this: www.myrailsapp.com/post/id here's the route: map.resources :posts, :has_many => :comments Any thoughts on how you would make the above this? www.myrailsapp.com/1djs34 (or some join of randomly generated letters and numbers) so

[Rails] Re: Limiting scope of :validates_uniqueness_of

2010-08-19 Thread Ze Ca
Ah, ok. That did it. I see now I would want to limit the scope to the post_id column, instead of the post table. Thank you! Rob Biedenharn wrote: > On Aug 19, 2010, at 11:23 AM, Ze Ca wrote: > >> >> I'm having a hard time limiting the scope of new comments to the

[Rails] Limiting scope of :validates_uniqueness_of

2010-08-19 Thread Ze Ca
I'm having a hard time limiting the scope of new comments to the Post model. So, for validates_uniqueness_of :title in the comment.rb model, that uniqueness would only be attached to the post I'm commenting to, not globally among all comments in the application. I tried putting this in comment.rb

[Rails] Re: Are those classes built-in?

2010-08-16 Thread Ze Ca
Hey, a question I can answer! :-) Those aren't ruby classes as you're probably thinking about. They're css classes and (from my limited knowledge of css) basically control the presentation of the text in between the tags. I'd look in the css file for "field" to see how it's being presented (fo

[Rails] Re: Re: Re: Re: Re: Re: using includes in rails models

2010-08-16 Thread Ze Ca
Thanks Philip. After reading your response, I tried doing another dummy application myself, and in the middle of getting everything set up, I realized that I didn't restart the script/server after adding the include. So I went back to my other application, and this worked. Occam's razor :-). S

[Rails] Re: Re: Re: Re: Re: using includes in rails models

2010-08-14 Thread Ze Ca
Hi Philip, I put the amatch gem in the environment.rb file as config.gem 'amatch' I tried the require 'amatch' in line 1 in each of my models and got this error: MissingSourceFile in PostsController#show no such file to load -- amatch Thank you! Phillip Ridlen wrote: > I believe you've inclu

[Rails] Re: Re: Re: Re: using includes in rails models

2010-08-14 Thread Ze Ca
Hi Philip, Sorry, I was actually asking two different questions in my last reply. You've answered my question about the console, thanks for your help! It's much clearer now. I've put the " include 'amatch' " in both my Post model and my Response model, which have a one to many relationship. Ho

[Rails] Re: Re: Re: using includes in rails models

2010-08-14 Thread Ze Ca
Philip, Thank you for your help, that worked! I put that extra code in the model, but I still get the uninitialized constant error in my browser when accessing the show action. Not sure what may be the issue. Thanks again for your help! Phillip Ridlen wrote: > In your console, you either need

[Rails] Re: Re: using includes in rails models

2010-08-14 Thread Ze Ca
rror in GamesController#show uninitialized constant Game::Amatch Thanks again! Chris Mear wrote: > On 14 August 2010 16:05, Ze Ca wrote: >>>> appreciated! >>> require 'amatch' >> Thank you for the reply. putting the include  under the model class, >> however, I

[Rails] Re: using includes in rails models

2010-08-14 Thread Ze Ca
s.add_to_base("Sorry, the last submitted response must have changed by one letter") if m.match(second_response) != 1.0 end That makes sense to me. I'm just curious why I wasn't able to make a new Sellers object in the first page? Thanks again for your help! Chris Mear

[Rails] using includes in rails models

2010-08-13 Thread Ze Ca
Hi, I'm trying to use the amatch gem (http://flori.github.com/amatch/) to help with some validations. In the documentation examples (http://flori.github.com/amatch/doc/index.html ), after the require 'amatch', there's an include Amatch. Where would I put this include? I tried putting it at the ve

[Rails] Re: Re: associate hidden field with another field in a form

2010-04-19 Thread Ze Ca
Colin Law wrote: > On 19 April 2010 15:32, Ze Ca wrote: >> a toy project meant for learning about hidden form fields. I'm mainly >> curious what I could do with them. > > Anything you put in a hidden form field will be available in the > params array in the control

[Rails] Re: associate hidden field with another field in a form

2010-04-19 Thread Ze Ca
Sharagoz wrote: > If you know the states name, then you automatically know the capitals > name, dont you? > So then it wouldnt be necessary to submit the capital name as a hidden > field, as you can retrieve it through the state object. > Or am I missunderstanding something? Hi Sharagoz, Thanks f

[Rails] Re: associate hidden field with another field in a form

2010-04-19 Thread Ze Ca
Colin Law wrote: > On 19 April 2010 08:10, Ze Ca wrote: >> In my form I have a select menu for US States. I would like to include >> the capitals of those states as a hidden parameter when passed to the >> model. Of course, the capital should match the state chosen. &g

[Rails] associate hidden field with another field in a form

2010-04-19 Thread Ze Ca
In my form I have a select menu for US States. I would like to include the capitals of those states as a hidden parameter when passed to the model. Of course, the capital should match the state chosen. I know I can set a attr_accessor :state_capitals in the model, or even make a migration to updat