ruby-on-rails-3.2

git push >> fatal: no configured push destination

落花浮王杯 提交于 2019-11-30 08:06:28
I'm still going through some guides on RoR and I'm stuck here at Deploying The Demo App I followed instructions: With the completion of the Microposts resource, now is a good time to push the repository up to GitHub: $ git add . $ git commit -a -m "Done with the demo app" $ git push What happened wrong here was the push part.. it outputted this: $ git push fatal: No configured push destination. Either specify the URL from the command-line or configure a remote repository using git remote add <name> <url> git push <name> So I tried following the instructions by doing this command: $ git remote

How to add confirm message with link_to Ruby on rails

核能气质少年 提交于 2019-11-30 08:03:49
I wanted to add confirmation message on link_to function with Ruby. = link_to 'Reset message', :action=>'reset' ,:confirm=>'Are you sure?' Any ideas why it's not working? First, you should verify that your layout have jquery_ujs . Best practice to do it by including it in your main application.js : //= require jquery_ujs Check that you included application.js in your layout: = javascript_include_tag :application While, in development mode, view your source html and verify jquery_ujs.js exists. Run your server and verify your link tag has data-confirm value, for example: <a href="/articles/1"

Display inline errors with simple_form in a Bootstrap Ajax modal

蓝咒 提交于 2019-11-30 07:37:58
问题 I've found similar StackOverflow questions here and here but still can't get this to work. I'm using Rails 3.2.8, SimpleForm 2.0.4, and Twitter Bootstrap 2.1.1 (via the bootstrap-sass gem 2.1.1.0). The user should be able to add a contact from a modal popup window. If there are validation errors, they should appear inline, just as if the user were using a non-modal version of the form (red border around field, error message next to field). I load the modal like this: <a data-toggle="modal"

Rails 3.2.17 Runtime Error Redirection Forbidden facebook

巧了我就是萌 提交于 2019-11-30 06:47:44
I have this code I use to get avatars from Facebook... if auth.info.image.present? user.update_attribute(:avatar, URI.parse(auth.info.image)) end When I try to load the code now I get this error: A RuntimeError occurred in authentications#create: redirection forbidden: http://graph.facebook.com/672086173/picture?type=square -> https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/t5.0-1/1086349_672086173_156380036_q.jpg /home/ubuntu/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/open-uri.rb:223:in `open_loop' I understand that this is a problem with Open-URI not allowing HTTP to HTTPS redirections...

Rails Controller Namespace

佐手、 提交于 2019-11-30 06:21:04
问题 What are advantages and disadvantages of using namespace in ruby on rails. For example: I've many controllers like CompanyLocations CompanyXXXX CompanySports CompanyActivites CompanyQQQQQ I want to put all these controllers in Company folder. What is the rails best practice for this ? 回答1: You have to create a subfolder inside your controller/ directory, and the same in your views/ directory. Your controller file should look like module Company class SportsController < ApplicationController

How to save a model without running callbacks in Rails

南笙酒味 提交于 2019-11-30 06:01:30
I need to calculate values when saving a model in Rails. So I call calculate_averages as a callback for a Survey class: before_save :calculate_averages However, occasionally (and initially I have 10k records that need this operation) I need to manually update all the averages for every record. No problem, I have code like the following: Survey.all.each do |survey| survey.some_average = (survey.some_value + survey.some_other_value) / 2.to_f #and some more averages... survey.save! end Before even running this code, I'm worried the calculate_averages is going to get called and duplicate this and

Set of CoffeeScript/JavaScript classes and methods available to rest of Rails app

隐身守侯 提交于 2019-11-30 05:35:43
问题 I'm using Rails 3.2.9. When I add CoffeeScript code to a .js.coffee file in the /app/assets/javascripts directory, I get the resulting JavaScript in all of my webpages. The problem is all the JavaScript is wrapped in: (function() { // my code }).call(this); So any methods I define are not visible in any other CoffeeScript code I write in other files. What's the proper way to write a set of reusable CoffeeScript classes and methods with Rails? 回答1: The simplest thing to do is to namespace all

Error, Ruby on Rails: Encoding::UndefinedConversionError in CoursesController#attachment “\\xFF” from ASCII-8BIT to UTF-8

空扰寡人 提交于 2019-11-30 04:58:12
I'd like to make a simple file uploader using tag_form on Rails 3.2.8. But when I try to submit a image file, I get an error saying Error Message (when I try to submit a image file) Encoding::UndefinedConversionError in CoursesController#attachment "\xFF" from ASCII-8BIT to UTF-8 I'd appreciate it if you help me with this problem. Here's my codes. app/view/show.html.erb <%= form_tag(attachment_course_path, :action=>'attachment', :multipart => true) do %> <div class="field"> <%= label_tag :file %> <%= file_field_tag :file %> </div> <div class="actions"> <%= submit_tag 'Submit' %> </div> <% end

Database Cleaner not working in minitest rails

风格不统一 提交于 2019-11-30 04:50:58
问题 My Minitest controller tests are working fine if I run them alone using rake minitest:controllers but when I run rake minitest:all then I get validation failed error. It is because email is already used in model tests. I used DatabaseCleaner to clean the database but unable to clean database. My code for database cleaner: require "database_cleaner" DatabaseCleaner.strategy = :transaction class MiniTest::Rails::ActionController::TestCase include Devise::TestHelpers def setup DatabaseCleaner

Authlogic doesn't work with my Rails 3.2 app

回眸只為那壹抹淺笑 提交于 2019-11-30 04:06:26
问题 I'm running Rails 3.2 and the latest version of Authlogic. When I run my app locally on my Mac, it works fine. When I try to run it on my production server (Ubuntu with Passenger/Apache), I get this: You must establish a database connection before using acts_as_authentic I'm not sure how to troubleshoot the problem. I posted this related question earlier today before I realized that the problem was broader than I thought. 回答1: I figured out the problem. Look at this snippet from Authlogic's