Michael Pavling wrote in post #990662:
> Something's wrong with your typing here or on the console, because
> your model should be "KnownIP" if you typed "$ rails generate model
> KnownIP". If the "p" is lower case in the model, you must have typed a
> lower case p...
No, i typed "$ rails generate model KnownIP" and got a model named
"KnownIp" in a file named "known_ip.rb".
> What do you mean "stop working"? The controller is still the
> controller, whether it is handling routes for "/known_i_p" or
> "/known_ip"...
Sorry, i haven't tested this for controllers, but if there is a mismatch
between a model name and its file name, the model is not working.
Example:
"KnownIP.create" gives "uninitialized constant KnownIP" if the model
file is named "known_i_p.rb" and not "known_ip.rb".
With controllers, which name should be used in the route, the name of
the file, or the name of the controller? :)
>> Another interesting example: if a model is generated with
>> $ rails generate model known_i_p ...
>> then it is broken from the beginning.
>
> Well yes, the name of the model should be the correctly cased name of
> the model... "known_i_p" is not...
According to
$ rails generate controller --help :
"Pass the controller name, either CamelCased or under_scored, and a list
of views as arguments."
It is true that
$ rails generate model --help
does not say this, but i assumed it should have been the same...
> I think the problem is you haven't actually said what you want to
> *do*. I don't know what "odd case" this shows. Do you mean you want to
> have a model called "KnownIp" but a table called "known_i_ps"? If so,
> why? What reason do you have for not having the table called
> "known_ips"?
> Or do you want your model called "KnownIP" but the model file called
> "known_ip.rb"? Again, what on earth for? What difference does the
> model's file name make in the scheme of things?
>
> The controller is a totally different issue - you can call a
> controller anything you like, it's not a 1:1 mapping to a model.
I want to have a model KnownIP and a controller KnownIPs controller, and
i want to choose myself how to name their files ("known_ip.rb" and
"known_ips_controller.rb", for example).
I also want to understand the rules and options about naming those
files, in order not to run into some model name or controller name which
would be *impossible* to store in *any* file :).
Alexey.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.