I'd like to see an example of an application generator template for Rails 3. Any suggestions?
I'm interested in an example of a template that is used to generate a new Rails application. Ryan Bates has a screencast (#148 App Templates in Rails 2.3) that describes how to create an application generator template for Rails 2.3 but I'd like to see how something similar is implemented in Rails 3. I've seen several tutorials on using the Rails 3 generators but I haven't found anything that shows how to create an application generator template.
I presume all of the capabilities of Thor and Rails::Generators::Actions are available but I'd like to see how to use them in an application generator template.
It seems terminology is confusing here. "View Template Engines" (such as Haml) are one thing; "Rails Generators" (such as used for "rails generate helper") are another thing; and "Application Generator Templates" (used for "rails new app_name -m some/path/to/template") are quite another thing.
Dug around in the Rails source and answered this question myself :-)
Here's an example of an application generator template for Rails 3:
http://github.com/fortuity/rails3-mongoid-devise/raw/master/template.rb
Usage:
rails new app_name -m http://github.com/fortuity/rails3-mongoid-devise/raw/master/template.rb
In customizing this template, you can use any methods provided by Thor::Actions
http://rdoc.info/rdoc/wycats/thor/blob/f939a3e8a854616784cac1dcff04ef4f3ee5f7ff/Thor/Actions.html
and Rails::Generators::Actions
http://github.com/rails/rails/blob/master/railties/lib/rails/generators/actions.rb
Related
Salesforce report builder is pretty awesome - see here http://www.salesforce.com/_app/video/chatter/help/report_builder.jsp.
Lots of my customers want similar functionality built into ruby on rails apps. I cant seem to find any good tool, framework or gem out there to do this sort of thing. Before I start building one myself, I wanted to see if anyone knew of something out there that was similar or could be used for the same purpose.
Assume I have a running ruby on rails app.
I’m creating classes (db-models) defined by a description provided at runtime.
Right now, I’m using the rails app (via browser) to trigger the code generation — and therefore the app “knows” about its new classes.
But, is it possible to inject code from scripts executed inside the rails app directory?
Like…
$ [path/to/app] rails s
$ [path/to/app] script/apply_schema
Since RoR supports many helpers for both generating tables, columns etc. I do not see why you want to do this using script injection. this would not only be a very weird way of inputting and rendering data but it would also create quite a security risk.
Then comes my second question (in runtime) how would you define authentication? since you are trying to inject code?
I would advise using the SQL helpers to create/update/destroy attributes. this is based on a much used and effective architecture. also using relations makes you able to build quite alot while still remaining in the "safe" environment RoR offers.
If you want to try a framework wich offers data injection on runtime try Meteor
I am using the Rhomobile framework to develop an application that is supposed to run on different mobile phones. The tutorial mentions how to write tests for the example model: Person. In fact, the framework provides a command-line tool rhogen spec to generate the dummy tests for the models. How would I go about writing tests for the controller class: PersonController? I was thinking of something similar to how one would do it in Rails, but rspec is unknown to me, and the methods post and redirect_to doesn't seem to work.
In BDD when you want to specify the behavior of the application (this is what controllers are responsible for) - you would normally aproach that with a StoryBDD framework - use for example Cucumber . Rspec is SpecBDD and regards a different level of abstraction - it is for specifying how classess communicate with each other and what they do.
You can find many tutorials on Cucumber's github page. This one could be helpful
I recently inherited a Rails 2.3 application that I'm now trying to upgrade to Rails 3. Cache-money is an integral part of the application so I want to make sure we have the same functionality in place when we go to Rails 3. However, my research on the subject has shown that cache-money is not compatible with Rails 3 (due to the use of unsupported AR methods :find_every and :find_from_ids).
I've seen a couple of comments and blogs mention that implementing the type of write through caching with Rails 3 that cache-money provided should be a trivial task. Any ideas on how to approach implementing write through caching with Rails 3?
Last week I launched a new write-through-cache gem for Rails 3, see
https://github.com/orslumen/record-cache.
The reason I built it, is because we were using cache money in a Rails 2.3 project and recently migrated to Rails 3. So chances are, it will also serve you well.
Writing your own write-though caching in Rails 3 does not sound like a trivial task to me. If you do find a trivial way, please be sure to copy me in on that.
I've been searching for an equivalent to Symfony's built-in Localized Schema which provides a native support for managing internationalized Tables/DB. Here is a link to Symfony's documentation covering their implementation of I18n & L10n, with the relevant part on Localized Schema (appx. a third down the page, such as the paragraph "Text Information in the Database").
I've checked out Globalize2 gem, but not sure as to whether it is fully supported in Rails3.
Also found the gem puret, which seems to have more recent commits/activity.
All in all though, it's very likely I am missing out on other possible options, as still getting my bearings in RoR dev.
Open to any info/suggestions you may have! ;)
Try gem named has_translations. It have been tested in several production sites for a one year already. Supports 1.9 + Rails 3. For any issues fill out form on the github.
https://github.com/dmitry/has_translations
Actually it's more or less the same as puret, but it was built when rails 2.3.5 was a mainstream, so I just supported it for a websites I've did already. I suggest you to choose between puret and has_translations, others is too magic or not maintained anymore. You can find more alternatives in has_translations README file.