ruby-on-rails-3

how to prevent bundler from adding platform info to Gemfile.lock

懵懂的女人 提交于 2020-01-02 07:12:26
问题 every time I run bundle --without=production bundler adds platform information PLATFORMS x86-mingw32 to Gemfile.lock and I have to remove that info manually as I am deploying to Heroku. If I do not remove it, Gemfile.lock is not added to repository and causes errors. how can I prevent bundler from adding platform info to Gemfile.lock 回答1: I had a very similar question - Can I stop Bundler from adding RUBY VERSION to Gemfile.lock - and it turns out the answer is that it can't be done. Bundler

Rails UTF-8 response

谁都会走 提交于 2020-01-02 07:10:46
问题 I've got a Rails 3.2 app running on Ruby 1.9.3 that returns JSON data stored in a MongoDB database. The data seems to be stored correctly in mongo, e.g. (look at the name attribute): { "_id" : ObjectId("4f986cbe4c8086fdc9000002"), "created_at" : ISODate("2012-04-25T21:31:45.474Z"), "updated_at" : ISODate("2012-04-26T22:07:23.901Z"), "creator_id" : ObjectId("4f6b4d3c4c80864381000001"), "updater_id" : null, "name" : "Trädgår'n", "sort" : "tradgarn", "address" : "Nya Allén 11", "coordinates" : [

changing database from PostgreSQL to MySQL in a Ruby on Rails app

风流意气都作罢 提交于 2020-01-02 07:01:12
问题 In my current application i am using PostgreSQL Data base, but I want to change the PostgreSQL database into MYSQL DB. if it's impossible ? 回答1: Step 1 Make a backup copy of your data For Rails 3, install the YAML DB gem: https://github.com/ludicast/yaml_db For Rails 2.x install the YAML DB plugin: script/plugin install git://github.com/adamwiggins/yaml_db.git Run the dump task rake db:dump Step 2 Update your config/database.yml file. Step 3 : gem install mysql Have rake create your database

Functional test and nested resource

混江龙づ霸主 提交于 2020-01-02 06:18:53
问题 I have a Story resource nested in a User resource. How do I fix this generate functional test? test "should create story" do assert_difference('Story.count') do post :create, story: @story.attributes end assert_redirected_to story_path(assigns(:story)) end DGM solution still have the story_url problem 回答1: You need to provide the user id it is nested in: post :create, story: @story.attributes, user_id: @user.id The path may be something like, user_story_path(@user.id, assigns(:story)) 来源:

Functional test and nested resource

好久不见. 提交于 2020-01-02 06:18:31
问题 I have a Story resource nested in a User resource. How do I fix this generate functional test? test "should create story" do assert_difference('Story.count') do post :create, story: @story.attributes end assert_redirected_to story_path(assigns(:story)) end DGM solution still have the story_url problem 回答1: You need to provide the user id it is nested in: post :create, story: @story.attributes, user_id: @user.id The path may be something like, user_story_path(@user.id, assigns(:story)) 来源:

Routing Error for a model with a join_table and has_many :through in RailsAdmin

白昼怎懂夜的黑 提交于 2020-01-02 05:26:24
问题 So I have 3 models: category , product , category_products . This is my category.rb attr_accessible :name has_many :category_products do def with_products includes(:product) end end has_many :products, :through => :category_products This is my product.rb attr_accessible :name, :description, :price, :vendor_id, :image, :category_ids belongs_to :vendor has_many :category_products do def with_categories includes(:category) end end has_many :categories, :through => :category_products This is my

How to update a model's “updated_at” field only for a subset of column updates?

百般思念 提交于 2020-01-02 05:24:06
问题 There is a typical blog application. Each user has_many posts. Each post has_many tags. I'm sorting each post by updated_at so the most recently updated post will show up on top. So for example, if I update a post's content, the post will come up to the top. However, this also happens when I just add a tag, since a tag is connected to its corresponding post. I only want the content update to change updated_at field. I don't want updated_at for a post to be changed because I added a tag. Is

apn_sender and Rails 3

血红的双手。 提交于 2020-01-02 05:22:27
问题 I have a project that needs to send notifications from server to device. I don't know how and where to start (create table first or other), because I'm new to Ruby on Rails. I've follow the apn_sender tutorial but it won't work and always errors out on start. Is there any full tutorial to create apn_sender for Rails 3? Thanks 回答1: Rails 3 and apn_sender I too have been working on the apn_sender problem, because I like that the Apple Push Notification support seems pretty robust. However, the

Start another Rails Server from within Rails App with backticks

廉价感情. 提交于 2020-01-02 04:48:06
问题 I'm currently working on a Rails application that serves as an Updater for another Rails application. I have the update process working, Download new release zip Extract to proper location Sync Assets Bundle install Precompile Assets Start server with - bundle exec rails server I'm having an issue with the last step. When I run: Dir.chdir('../other-project') `bundle exec rails server -d -p 3000` from the updater app it seems to be pulling from the updaters bundle and not the new application

What is covered by save(:validate => false)?

主宰稳场 提交于 2020-01-02 04:44:06
问题 I just implemented a number of custom counter_cache s using code like this: def after_save self.update_counter_cache end def after_destroy self.update_counter_cache end def update_counter_cache self.company.new_matchings_count = Matching.where(:read => false).count self.company.save end My question is this - what does the command Model.save(:validate => false) actually prevent beyond things like validates_with or before_validation ? Will my custom counter_caches be affected if I keep my