So where rails store its standard helpers, like form_tag - helper? i recently installed twetter-bottstrap-rails. So this gem provides some helpers that can be used in views to generate bootstrap-styled HTML. Where this helpers are stored? App/helpers - is empty - so this helpers must in the same place where standard rails helpers are.
Twitter-bootstrap-rails helpers are in twitter-bootstrap-rails gem:
https://github.com/seyhunak/twitter-bootstrap-rails/tree/master/app/helpers
Rails' form_tag is defined here: http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html
However, that won't answer your question - the helpers that twitter-bootstrap-rails provides will be in the gem itself. See: https://github.com/seyhunak/twitter-bootstrap-rails/tree/master/app/helpers
Related
I'm working on a private gem for Rails which includes a controller helper.
I doubt between these two places for this helper:
lib/gem_name/my_helper.rb
app/controllers/concerns/gem_name/my_helper.rb
What is the correct place for it?
I think you should use it in controller concern, then include helper module into Application controller
So I will prefer app/controllers/concerns/gem_name/my_helper.rb for creating controller helper inside gem.
This is the first time I'm trying to build a gem. I use bundle gem MyGem
there are three directories inside MyGem. bin lib MyGem. I want to create controller model, helper inside it I tried scaffold but didn't worked for me any idea !!!
Use Rails Engines instead of a gem, which can include controllers, models, helpers, routes and other Rails elements.
bourbon uses font-url here.
Rails has the method font_url which I'm fairly certain is what is being invoked. However, I can't find where the connection between these two things is made. I have explored the codebases of bourbon, sass, sass-rais, and rails.
Where is font-url defined, and/or the connection between it and rails's font_url made?
update
Clarification: my ultimate goal is to define my own helpers in rubyland which are siblings to font_url.
font-url is a part of rails asset pipeline just like image-url. If you look at rail guides it clearly says
When using the asset pipeline, paths to assets must be re-written and sass-rails provides -url and -path helpers (hyphenated in Sass, underscored in Ruby) for the following asset classes: image, font, video, audio, JavaScript and stylesheet.
So if you are using font-url("some_font") it will look for some_font in app/assets/font directory
Update:
As it is mentioned in docs that if you are using sass then your can use your assets with hypenated urls(image-url) but if you are using a ruby file then those helpers would be underscored (image_url) probably because Ruby doesn't like you having methods or variables with hyphens in the name syntactically, but semantically, there's nothing wrong with it
Has anyone encountered an equivalent to HTMLPurifier for Rails apps? Essentially I need to clean up often terribly formed HTML generated by users before saving to the DB.
http://htmlpurifier.org/
You can use the sanitize method.
sanitize(html)
There is also a Sanitize gem.
Sanitize.clean(html)
I tend to prefer the Sanitize gem because it can be used as a before_save filter in your models instead of having to use the sanitize method in each of your views.
Where can I find a complete list of Rails helper functions (such as form_for)?
Most of them are under ActionView::Helpers in documentation.
javascript helpers
form helpers
url helpers
tag helpers
asset tag helpers
date helpers
There are more available, so downloading Rails source and looking under action_view/helpers is likely your best bet.
ApiDock is a pretty good source of documentation. Check out http://apidock.com/rails/browse under ActionView::Helpers.
Also Obie Fernandez's book "The Rails Way" has a comprehensive (I believe) chapter on them.