ruby-on-rails-3

Twitter Bootstrapping a locale selector drop-down in Rails 3

两盒软妹~` 提交于 2019-12-25 03:07:10
问题 I have a non-Bootstrapped locale selector in my otherwise generally Bootstrapped Rails 3 app that I want to Bootstrap-ify. I'm a bit stumped as to how to make an (I assume) unordered list in a form in a dropdown menu. TL;DR Go to Edit 3 at the bottom of this question for the completed solution. The current code is implemented in the following way: app/views/layouts/_header.html.haml %header.navbar.navbar-fixed-top .navbar-inner .container # ... %nav %ul.nav.pull-right # ... %li= render

How to use inline :confirm option for html helpers with AJAX calls?

丶灬走出姿态 提交于 2019-12-25 02:56:08
问题 I am trying to have an AJAX implementation of record deletion associated with a button. The problem is that ajax:success event doesn't seem to be triggered in such case. I have implemented the suggestion from this post: Rails :confirm modifier callback?) but I am uncertain if it's the preferred way. I was wondering if communal wisdom could help in this case. What's the right approach here? app/views/competitions/show.html.haml: %td= button_to 'Delete', contender, remote: true, method: :delete

Not able to test cron job using whenever gem in rails 3

此生再无相见时 提交于 2019-12-25 02:51:34
问题 I did the following to implement cron jobs in rails 3 using a "runner" instead of a rake task. Step 1: I have whenever gem installed and scheduler.rb has following: set :environment, 'development' set :output, { :error => "/log/error.log", :standard => "/log/cron.log" } every 1.minute do runner "Cron.sendAutomaticsSMS()" end Step 2: Cron file: lib/cron.rb class Cron < ActiveRecord::Base def **sendAutomaticsSMS**() ----some code here --- end end Step 3: whenever --update-crontab --set

Not able to test cron job using whenever gem in rails 3

十年热恋 提交于 2019-12-25 02:51:31
问题 I did the following to implement cron jobs in rails 3 using a "runner" instead of a rake task. Step 1: I have whenever gem installed and scheduler.rb has following: set :environment, 'development' set :output, { :error => "/log/error.log", :standard => "/log/cron.log" } every 1.minute do runner "Cron.sendAutomaticsSMS()" end Step 2: Cron file: lib/cron.rb class Cron < ActiveRecord::Base def **sendAutomaticsSMS**() ----some code here --- end end Step 3: whenever --update-crontab --set

How do you get rspec to output what it encountered rather than it “didn't find what it expected”?

余生长醉 提交于 2019-12-25 02:50:32
问题 I have been struggling to using ruby/rspec/capybara/devise to test my code. A simple test I am trying to write is for signing in. I have a valid user sign in and expect to see an h1 tag as defined in the following code: describe "Authentication" do subject { page } describe "with valid information" do let(:user) { FactoryGirl.create(:user) } before { sign_in_with user.email } it { should have_css('h1', text: "Welcome to the Test") } end end Problem is that I get this in return: 1)

Include JavaScript in Ruby (on Rails)

牧云@^-^@ 提交于 2019-12-25 02:41:55
问题 I don't quite understand how Rails includes JavaScript files. Google and the following documentations didn't solve my problem: http://railsapps.github.io/rails-javascript-include-external.html http://guides.rubyonrails.org/asset_pipeline.html I understand that Rails uses manifest-files (e.g. applications.js) to pack every included JavaScript file into one big file (performance reasons, etc.). In application.html.erb you need to include this manifest, like <%= javascript_include_tag

creating a button/link with Json params

痞子三分冷 提交于 2019-12-25 02:38:28
问题 I got this in a controller: def create if save respond_to do |format| format.html { render "crop" } format.json { render json: @user, status: :updated, location: @user, notice: "updated" } end end The above respond_to will render .com/user/:id (users/crop.html.erb) Instead of rendering crop.html.erb after create method, I need a link which would take user to the same page. <%=link_to "crop", render "crop", render json: @user, location: @user %> <- don't know whow to write this one. Would

Is a Rails Model a normal ruby class that can be used to store state between different controller actions? No active-record and no-database at all

心已入冬 提交于 2019-12-25 02:38:06
问题 So I'm finally starting to get the hang of rails I think. :-) I need to step away from the standard Model (database) to: Controller to: View data exchange flow and stick in my own business logic non-database class as the Model. I have a few questions. I think of models as ORM to a database table. But are these models just regular java classes that can be used to store state? Because I need to use a basic ruby class that isn't going to be active-record based. I'm planning on using it to store

Heroku: Could not find libv8-3.15.11.1 in any of the sources

偶尔善良 提交于 2019-12-25 02:37:09
问题 I know there are a lot of these questions on Github (I've looked through all of them), but none of the answers have worked for me. I am getting the error "Could not find libv8-3.15.11.1 in any of the sources" when I try "git push heroku master." I specify the version of libv8 in my Gemfile (with gem "libv8", "~> 3.11.8.13"), and I think this is reflected in my Gemfile.lock ("libv8 (3.11.8.13)"). I don't understand why it's looking for version 3.15.11.1 when I've specified 3.11.8.13. I made

Modify Devise alerts ( Rails 3)

走远了吗. 提交于 2019-12-25 02:33:03
问题 I am using devise in my rails app which comes with its own alert/flash helpers. I have modified it so that it looks like this <% flash.each do |key, value| %> <%= content_tag(:div, value, :class => "flash #{key}") %> <% end %> What i want to do is to be able to close this alert with a X in the top corner, rather than refresh the page to make it disappear. I have created an alert box with css/jquery and surrounded the relevant divs around the above code, however as its in the layouts