I'm surprised to see how simple is to customize things in rails.
You start by installing a gem that provides some functionality you need and then you just customize what you need to.
An example is Spree, which can be customized by simply overriding templates and ruby files with custom code.
I'm just wondering who's allowing me to do this:
Is it Ruby?
Is it the architecture of these Gems?
Is it the Rails architecture?
Ruby allows meta-programming since its evaluated at runtime.
In a rails application, you can add classes like ruby String to the initializers folder and add new declarative methods, which will then be added to the String class and can be used with Strings.
Read more http://www.vitarara.org/cms/ruby_metaprogamming_declaratively_adding_methods_to_a_class
It's part rails and part ruby. Rails has been written (and has been rewritten to be more) extendable by developers and plugins over the years. Certain ways of hooking in and overriding functionality are enabled through ruby and others would be the same in many less dynamic languages.
Related
I'm in the process of creating a rubygem which will be used with both Sinatra and Rails applications. Ideally, I'd like to have a single gem which can work with both frameworks. It's very simple - it provides some helpers, styles, scripts and view partials.
For Sinatra, I use the register method to register the module, which in turn adds the helpers, adds some entries to the load paths and optionally creates some actions/routes. So far so good.
My question is: What is the rails equivalent of this? Engines?
Since you need to define routes, I think a rails engine would work best.
You can load helpers with railties too, but I don't think it's possible to define routes with railties.
Rails Engines:
http://edgeguides.rubyonrails.org/engines.html
Railties:
http://edgeapi.rubyonrails.org/classes/Rails/Railtie.html
May I ask you how to make rails web design more efficient?
Is compass plus blueprint the perfect match?
Is the current version of compass support rails3.1
Are there any other frameworks that will make rails web deign easier?
Thanks
Definitely a framework like compass is awesome, it includes a lot of helpers, and provides a good solid base.
For form-styling I would recommend using a gem like [formtastic][1], which not only greatly simplifies making forms, but also provides a standard css file. So all needed tags are then known (and can be overwritten if needed).
There a few alternatives to kickstart your application's layout:
twitter-bootstrap: it is plainly awesome and provides a great start (it does not play nice with formtastic, but works perfectly well with simple_form).
web-app-theme provides generators, and a set of templates to style your application quickly
activo is a template that is contained in web-app-theme, but can also be used standalone
Hope this helps.
Since there are so many options there available for internationalization of a rails app, which gems or plugins are the best (today) for adding i18n support to a rails app.
Im using I18n bundled with rails for the application messages, button labels, and model attribue names.
But I also need to let the users to input content and the translated version of the content, but there are so many options for this right now that I don't really know which one to use.
We at Mynewsdesk (the guys behind the translate plugin) has moved on, now we're using Web Translate It to manage our locales. We've bloged about our translation workflow.
I like this one:
https://www.github.com/mynewsdesk/translate
because it has a nice webGUI for translating new/changed strings
I want to create a framework for rails application. It will be a rails application but packed into gem (like a Radiant CMS).
It must work like this:
gem install cmsframework
and then:
cmsframework the_app
After that we have a skeleton framework for a rails app, without any controllers, etc. All controllers are loaded from cmsframework gem.
If I want to rewrite some files (for example public/styles.css), I must simply create it in my app (the_app).
If I want new functions in my app I can create a plugin. But the main functionalities must be loaded from cmsframework gem.
What is the best way to implement this?
Maybe start here: http://guides.rails.info/plugins.html. Pay close attention to the parts about adding custom generators and packaging as a gem. This may help as well: http://railscasts.com/episodes/218-making-generators-in-rails-3.
You can use this framework it is very good CamaleonCMS
What changes do you need to make to a Rails project to configure blueprintcss as the default stylesheet to be used when you generate scaffolding instead of scaffold.css?
I'd recommend writing your own generator, but if you want to alter the default you can:
1 - For a single app: Freeze rails and change the stylesheet the scaffold generator uses.
railsapp/vendor/rails/railties/lib/rails_generators/generators/components/scaffold/templates/style.css
2 - For all apps: Change the same style.css file in your systems rails installation.
Substitute your own scaffolding generation code. Instructions are here (with the caveat that they may be out of date).
An easier alternative may be to write a Rake action to do textual substitution in the (normally) generated source.
Look into Rails Templates.
You can write one to do much more than replace the css in a rails app. YOu can make it install gems, freeze rails, all kinds of things. Take a look at http://youvegotrails.com for an idea of what you can do.