Rails: How to add link_to with target blank

Why would you want to override link_to? It’s already defined in Rails, just use it like this : link_to “GOOGLE”, “http://www.google.com”, target: “_blank”, class: “btn btn-large btn-primary” Edit: OK, understood. I’d advise against overriding such a common method so create another one : def link_to_blank(body, url_options = {}, html_options = {}) link_to(body, url_options, html_options.merge(target: “_blank”)) … Read more

Subqueries in activerecord

Rails now does this by default 🙂 Message.where(user_id: Profile.select(“user_id”).where(gender: ‘m’)) will produce the following SQL SELECT “messages”.* FROM “messages” WHERE “messages”.”user_id” IN (SELECT user_id FROM “profiles” WHERE “profiles”.”gender” = ‘m’) (the version number that “now” refers to is most likely 3.2)

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