ruby-on-rails-3.1

Rename session cookies in Rails

余生长醉 提交于 2020-05-29 02:30:47
问题 since I'd like the session cookie to reflect the url and not the app name, I'd like to rename the cookies.. The current session cookie name is called _APPNAME_session is there a way to rename it to _somethingelse_session ? I see the name of it when I do curl -i <appurl> I see set_cookie = _APPNAME_session=.... 回答1: In config/initializers/session_store.rb, set/change the following line: For Rails < 5.0.0: <APPNAME>::Application.config.session_store :cookie_store, key: '_somethingelse_session'

Rename session cookies in Rails

自闭症网瘾萝莉.ら 提交于 2020-05-29 02:30:17
问题 since I'd like the session cookie to reflect the url and not the app name, I'd like to rename the cookies.. The current session cookie name is called _APPNAME_session is there a way to rename it to _somethingelse_session ? I see the name of it when I do curl -i <appurl> I see set_cookie = _APPNAME_session=.... 回答1: In config/initializers/session_store.rb, set/change the following line: For Rails < 5.0.0: <APPNAME>::Application.config.session_store :cookie_store, key: '_somethingelse_session'

link_to with target blank

余生长醉 提交于 2020-05-10 06:53:27
问题 I am new to rails 3, I would like to add (:target => "_blank") to link_to helper below link_to "GOOGLE", 'http://www.google.com', class: "btn btn-large btn-primary" But I would like to use the application_helper to define link_to method. How do I define the link_to methd in application_helper? How do I pass the class: "btn btn-large btn-primary" in the link_to method? Thank you for your assistance... 回答1: Why would you want to override link_to ? It's already defined in Rails, just use it like

Html5 audio won't play in safari when the source is populated via JavaScript

浪子不回头ぞ 提交于 2020-04-15 22:39:36
问题 I am building a playlist in my Rails app and I am having some issues getting audio to play in Safari. If the html5 audio element's source is hard-coded, it plays just fine in safari but when it is populated via javascript, it does not play. this works just fine in Chrome and IE, but not in Safari. Here is the Ruby for the playlist entry: .playlist_column -@music_posts.each do |post| .entry{:id => post.id, :data => {:post_id => post.id, :source => post.mp3.url}} and here is the audio element,

How to set SameSite attribute to 'None; Secure' in Rails3.1.12 and Ruby1.9.3

可紊 提交于 2020-04-07 04:13:12
问题 A cookie associated with a cross-site resource at https://example.com/ was set without the SameSite attribute. It has been blocked, as Chrome now only delivers cookies with cross-site requests if they are set with SameSite=None and Secure . You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032. Please let me know how to set the SameSite

ransack search form in header partial: No Ransack::Search object was provided to search_form_for

為{幸葍}努か 提交于 2020-02-26 07:33:04
问题 First of all, I'm new to RoR, so the answer may be obvious, in which case I apologize. I've looked around and haven't found anything that helps. I'm trying to have a search form at the header of every web page on my app that will search through the names of all my "buckets". Here is the relevant code: In app/views/layouts/_header.html.erb (within a nav bar): <% search_form_for @q do |f| %> <%= f.label :name_cont %> <%= f.text_field :name_cont %> <%= f.submit %> <% end %> In app/controllers

show data from table on Ruby

与世无争的帅哥 提交于 2020-02-06 06:16:09
问题 I am new on Ruby and I am trying get data from table. so when read this <%= puts @note.inspect %> I have this this result. [#<Note id: 1, user_id: 1, note_type: 0, text: "Barev dzez", lat: 40.2290542420142, lng: 44.420879046875, deleted: false, created_at: "2012-04-26 14:10:05", updated_at: "2012-04-26 14:10:05">] So when I call Note.text (for instance) I got nil result. So what should I write here to get data from array? Thanks 回答1: @note is an Array with one Note object. You need to get the

show data from table on Ruby

房东的猫 提交于 2020-02-06 06:15:08
问题 I am new on Ruby and I am trying get data from table. so when read this <%= puts @note.inspect %> I have this this result. [#<Note id: 1, user_id: 1, note_type: 0, text: "Barev dzez", lat: 40.2290542420142, lng: 44.420879046875, deleted: false, created_at: "2012-04-26 14:10:05", updated_at: "2012-04-26 14:10:05">] So when I call Note.text (for instance) I got nil result. So what should I write here to get data from array? Thanks 回答1: @note is an Array with one Note object. You need to get the

show data from table on Ruby

让人想犯罪 __ 提交于 2020-02-06 06:15:06
问题 I am new on Ruby and I am trying get data from table. so when read this <%= puts @note.inspect %> I have this this result. [#<Note id: 1, user_id: 1, note_type: 0, text: "Barev dzez", lat: 40.2290542420142, lng: 44.420879046875, deleted: false, created_at: "2012-04-26 14:10:05", updated_at: "2012-04-26 14:10:05">] So when I call Note.text (for instance) I got nil result. So what should I write here to get data from array? Thanks 回答1: @note is an Array with one Note object. You need to get the

Skip before filter with Active Admin

风格不统一 提交于 2020-01-29 10:38:04
问题 I am using devise and recently added active admin, which created a separate table of admin_users to keep admins. All works fine with Active Admin when I try to log in and browse around. However, my application controller has this for general users: before_filter :authenticate_user!, :except => [:show, :index] Because of this, when inside the active admin interface, whenever I try to edit or delete anything, it asks me to log in. I learned that a skip_before_filter can be used inside the