ruby-on-rails-3

undefined method `key?' for nil:NilClass with bcrypt-ruby and has_secure_password [closed]

本秂侑毒 提交于 2019-12-25 04:02:44
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I'm going through DHH's Agile Web Development with Rails for Rails 3.1. In chapter 14 they create a Users sign-in model/view/controller using the has

Configuring Google Annotated Timeline

久未见 提交于 2019-12-25 03:59:42
问题 I have a working Google Annotated Timeline (see docs at http://code.google.com/apis/chart/interactive/docs/gallery/annotatedtimeline.html). I would like to explicitly set a start_date and end_date, I presume by using zoomStartTime and zoomEndTime . But, I cannot get it to work and I think it's either because my syntax is wrong or because I'm using the wrong format for dates. My last line of the function: chart.draw(data, {'displayAnnotations': true}, {'zoomStartTime': new Date(2011, 6, 26)},

Devise after_sign_in_path_for works, but not the other ones

此生再无相见时 提交于 2019-12-25 03:56:26
问题 I'm really missing something here. I have read many things about devise redirects (seems like it is hard to implement for most people ...) but in my case I really don't get it. Sometimes I read that the methods after_<action>_path_for(resource) should be in the ApplicationController , sometimes it is mentionned to be in a specific controller, overriding the devise one. I'd rather have them in my ApplicationController since it bothers me to create more Controllers just for a redirect, but if

Rails: How to migrate a database where I added a :belongs_to relationship?

北城以北 提交于 2019-12-25 03:56:12
问题 This is my first rails app, one I'm creating for the sole purpose of learning rails. I created an app where I have Users and Products (and sessions, but this is not relevant here). After doing a rake db:mograte creating a few items and testing, I then wanted to add a relationship, where products belongs_to :users and a users has_many :products. But of course, since I have already created the tables, there isn't any column there to save this information. How do I make a migration on the

`accepts_nested_attributes_for`, but only modify the first child

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 03:53:17
问题 A Brief Background I'm making a conventional forum to learn/practice Rails. User Model has_many :topics has_many :posts Topic Model has_many :posts belongs_to :user Post Model belongs_to :user belongs_to :topic However, when a User is creating a new Topic, I also want them to simultaneously create the first Post within that topic (just like forums work). Additionally, when the Topic creator edits the Topic, he also edits the first Post. So, I added accepts_nested_attributes_for :posts to the

accepts_nested_attributes_for not saving the child attribute to the database

我与影子孤独终老i 提交于 2019-12-25 03:50:37
问题 My accepts_nested_attributes_for only saves the parent and not the child (nested) attributes. This is many_to_many relationship between parent and child. Problem: nothing happens and nothing is saved. But on the page, I get this message: utf8: "\xE2\x9C\x93" authenticity_token: 9Pjxt7e5RRgWVGafRyMoDqBSqmtj/R2zBSiVxGGxFOI= parent: !map:ActiveSupport::HashWithIndifferentAccess name: "Test" gender: Male children_attributes: !map:ActiveSupport::HashWithIndifferentAccess "0": !map:ActiveSupport:

Customize deals app's homepage and emails thanks to user history: how to do it the right way on Rails/postgreSQL?

半腔热情 提交于 2019-12-25 03:49:43
问题 I’d like to customize : 1. The order of the deals on the homepage 2. Emails depending on the deals a user has seen. Thanks to people on SO, it seems that the best would be to have 3 models and tables "standard_user", "deals" and "deals_participation" in order to have the many-to-many relationships the app need , a link table with to as follows: class DealParticipation < ActiveRecord:Base #This means the deal_participations table has a standard_user_id key belongs_to :standard_user #This means

Multifield/range validation

。_饼干妹妹 提交于 2019-12-25 03:47:13
问题 how would I validate that one field of my Model is "smaller" compared to another? class Event < ActiveRecord::Base validates :start, :presence => true validates :stop, :presence => true end In addition - how could I make sure that the "difference" between the two values doesn't exceed a maximum range? Cheers 回答1: I have a validation that's similar to this to make sure school years begin before they end and are not longer than a year. validate :beginning_before_ending, :not_longer_than_year

Filterrific not filtering data

故事扮演 提交于 2019-12-25 03:40:59
问题 I am trying to use Filterrific gem to filter data. but seems like every time I type in the text field, it just refreshes page and filter. I don't want it to refresh the page and it should be instant. Model: filterrific( default_filter_params: {}, available_filters: [ :dictionary_word_filter ] ) scope :dictionary_word_filter, lambda { |dictionary_word| where("dictionary_word LIKE :search", search: "%#{dictionary_word}%") } Controller: def index dictionary_types = DimDictionary::DISPLAY_TYPE

Rails 4 / postgresql 9.4 - Query and update a ruby object inside an array

末鹿安然 提交于 2019-12-25 03:38:21
问题 I have a method (find_by_sql) that outputs a ruby object inside an array like this: [#<deal id: 66480, opportunity_id: 4, admin_user_id: 1, created_at: "2015-09-20 18:37:29", updated_at: "2015-09-20 18:37:29", deal_available: true>] How can I update the object's 'deal_available' attribute inside my database in raw postgresql ? I tried different ways to write it but I stumble on the fact that it's very specific: it's an array, and inside there is a ruby object and I must manage to tell