ruby-on-rails-3.2

Rails session record not deleted from sql

时间秒杀一切 提交于 2019-12-13 05:24:19
问题 I see that when I click logout, I set the session variables to NIL and call reset_session. I see that the entry from the SQL DB is not deleted on this (but the session looks to get invalidated). I see that though the entry in SQL is not deleted for the session id, the data in the session gets changed on executing the destroy call. def destroy session[:user_id] = nil reset_session end I am running on rails 3.2.13. The destroy does not remove the entry from SQL: mysql> select * from sessions; +

Creating association with .build and working around parameter validation

淺唱寂寞╮ 提交于 2019-12-13 04:48:31
问题 Using Rails 3.2.9 I'm attempting to build a association using .build instead of .create but getting a password validation error that I can't seem to find a workaround. Review below: The way I understand to save a item with a association that is built using .build you actually have to do the save in this case on the owner. If you do a save on the @item it just creates the item and not the association(meaning it doesn't save to the DB until current_owner.save). when i do a save on the owner i

Rails Asset Pipeline JS Compression Inserting “Illegal Characters”

别等时光非礼了梦想. 提交于 2019-12-13 04:45:29
问题 I just asked a question about an "Illegal Character" in my javascript. The answer there led me to find that there is a problem with compressing javascript in the Rails asset pipeline inserting various Illegal Characters. The error I was receiving in the post was: SyntaxError: Invalid character '\u0008' I found that not using compression caused this to go away completely ... but I want compression! That error was found using the Rails default uglifer gem. I thought maybe it was a bug with that

Rails: dynamically changing form content

半城伤御伤魂 提交于 2019-12-13 04:38:35
问题 I am building message app in rails where user can send message from templates. I have a database of templates, and the user can select templates as per category. In my message model, I want to render the template dynamically based on category selected. I looked for examples on google, but was not able to find a relevant solution. This is my message form: <%= form_for @message, :html => {:multipart => true} do |m| %> <%= m.select :biz_case, options_for_select(Message::Bcase), :prompt =>

ajax in rails with collection_select

五迷三道 提交于 2019-12-13 04:33:56
问题 H everyone I am try to refresh this div #my_id4 with the request of the consult that I execute when change a collection_select with ajax. I have in my view the select with javascript like this... =collection_select(:department, :id, Department.all, :id, :name, options={:prompt=>"Seleccione departamento"}) this is the javascript code :javascript $(document).ready(function(){ $('#department_id').change(function(){ $.ajax({ url:"movements/find_by_department", type: "GET", data: { valor: $('

Rails 3.2.13 - Delete Entry From Nested Attributes

梦想的初衷 提交于 2019-12-13 04:29:44
问题 I have a Ruby on Rails 3.2.13 application where I have a collection_select statement. The collection_select statement is in a fields_for statement where I gather selected ids from the collection_select and use them to populate another table. The problem I am having is that the collection_select statement adds a null id entry in the array that stores the collection of selected ids. Here is my code in my view: <%= f.fields_for :media_topics do |media_topic| %> <%= media_topic.label :topic,

Rails3+Devise+Simple_form: Singular resource & simple_form_for errors in path helper

喜夏-厌秋 提交于 2019-12-13 03:44:55
问题 Got 2 questions: How can I get the simple_form_for to work with singular resource :foo_object that's associated to :users (see code excerpts below)? I get NoMethodError: undefined method foo_objects_path for @foo in the simple_form_for line. foo_object_path has a valid path but it seems simple_form_for is using the plural version. I've google'd & read SO posts regarding singular resource and path issues, but haven't found a solution to this. Do I need to create a nested resource for :foo

Can I hook into ActiveRecord connection establishment?

我与影子孤独终老i 提交于 2019-12-13 02:22:49
问题 I would like to add a user-defined function using Sqlite3's create_function, which will be used by database triggers. Is there a way to hook into ActiveRecord connection establishment to run some code each time a connection to the database is made, where one could create the function and make it available to the triggers? This would also be useful for setting pragmas on the connection. 回答1: Here is what I've found on my own. Using an initializer in app/config/initializers I do this:

Can't Edit Or Delete Javascript in Rails

微笑、不失礼 提交于 2019-12-13 01:44:02
问题 I'm having a really weird problem with Rails 3.2. None of the edits I make to 'app/assets/javascripts' has any effect on my app. I even completely removed all files from this directory and the scripts (which should have disappeared) continue to function like before. Here are the server logs when I've removed all js files have been removed from 'app/assets/javascripts' Started GET "/article/4" for 127.0.0.1 at 2013-05-23 15:37:55 +0900 Processing by ArticleController#show as HTML Parameters: {

Omniauth Nginx Unicorn callback to wrong host URL

久未见 提交于 2019-12-13 01:27:14
问题 I've deployed a Rails app to a VPS server, and I'm using the Nginx/Unicorn combo, everything works fine, except that for some reason beyond my understanding, the Omniauth callbacks redirect wrong, ie. http://unicorn/users/auth/linkedin/callback?oauth_token=95218ed3-b426-45ab-b022-693d2a2447cb&oauth_verifier=25955 it should instead be: http://my-real-domain.com/users/auth/linkedin/callback?oauth_token=95218ed3-b426-45ab-b022-693d2a2447cb&oauth_verifier=25955 What's wrong? why is the callback