Official way of adding custom fonts to Rails 4?

Yes the link given will explain it well, however if u need another detailed explanation then here it is Firstly to use custom fonts in your app you need to download font files, you can try https://www.1001freefonts.com/ and look for fonts Few of the most popular font file formats are mainly .otf(Open Type Format) .ttf(True … Read more

Rails 4 + append_view_path

The Devise gem has a way of adding views lookup path by overriding the _prefixes method: class DeviseController < Devise.parent_controller.constantize include Devise::Controllers::ScopedViews # Override prefixes to consider the scoped view. # Notice we need to check for the request due to a bug in # Action Controller tests that forces _prefixes to be # loaded … Read more

Filtering on activerecord relation without additional sql query?

The ActiveRecord:Relation only queries the db when its elements are accessed. So the sequence you have will not call the db at all unless you write something like u.first or tens.first. It is a bit different in Rails console as each statement results are printed to console so it executes the query each time. You … Read more

Trying to get a POST to return 400 bad request

The behaviour is as follows: Handling of Unpermitted Keys By default parameter keys that are not explicitly permitted will be logged in the development and test environment. In other environments these parameters will simply be filtered out and ignored. Additionally, this behaviour can be changed by changing the config.action_controller.action_on_unpermitted_parameters property in your environment files. If … Read more

Why does Rails 4 scaffold create json.jbuilder files?

To answer the “why” part: The relevance of scaffolding in Rails has somewhat shifted over the years. It is no longer meant to generate necessary code which couldn’t be abstracted away easily. Today it is mostly an educational tool to provide you with a somewhat dynamic example and demonstrate best practices. (That’s also the reason … Read more

Strange error in rails – missing helper

The problem seems to have been introduced in the latest version of ruby, ruby 2.2.0. Try this experiment: in rails console/or irb: [1] pry(main)>File.expand_path (“./”) => “/users/xxxx/Sites/xxxx” and in the terminal window: ]$ pwd /users/xxxx/sites/xxxx See the different case? If you get that, then deep in the bowels of active support a regex goes south. … Read more

Rails 4 skipping protect_from_forgery for API actions

An attacker could CURL at your controllers all they like, but if your API requires authentication, they wont get anywhere. Making the API consumers send a CSRF is not really what CSRF does. To do this you’d need to implement a type of knocking mechanism where your client hits an authorization endpoint first to get … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)