Rails

Ubuntu RVM Rails bash command not found

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I just installed ubuntu, and after that I wanted to install RVM with ruby and rails 3.1. Installations went fine but when I want to create a rails app it can't find the rails command. I know I can create an alias, but when rvm changes its gemset, the alias-path would be wrong right? This is my .bashrc file (/home/user/.bashrc): # ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples # If not running interactively, don't do anything [ - z "$PS1"

How to skip transaction in ActiveRecord for INSERT ONLY statement?

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Look at this example: 2.1.3 :001 > Stat.create! (0.1ms) BEGIN SQL (0.3ms) INSERT INTO `stats` (`created_at`, `updated_at`) VALUES ('2015-03-16 11:20:08', '2015-03-16 11:20:08') (0.4ms) COMMIT => #<Stat id: 1, uid: nil, country: nil, city: nil, created_at: "2015-03-16 11:20:08", updated_at: "2015-03-16 11:20:08"> As you can see the create! method execute insert statement inside useless transaction. How to disable transation in this case only (without disabling them in whole application)? 回答1: How it works: The persistence module define create

How to do live reload with Rails 4 and Ruby 2.0 app?

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to see live changes in browser if I edit .scss or .erb file in text Editor in Rails 4 + Ruby 2.0 project. I tried Guard and Guard-live-reload, but it's throwing the following error. 22 : 58 : 04 - ERROR - Could not load 'guard/rspec' or find class Guard :: Rspec 22 : 58 : 04 - ERROR - /home/ jitendra /. rvm / gems / ruby - 2.1 . 1@global / gems / guard - 2.6 . 1 / lib / guard / plugin_util . rb : 100 : in `require' > [#] /home/jitendra/.rvm/gems/ruby-2.1.1@global/gems/guard-2.6.1/lib/guard/plugin_util.rb:100:in ` plugin

Ruby on Rails: “couldn&#039;t find file &#039;jquery-ui&#039;”

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've just done a fresh install and was able to access the default rails page at localhost:3000, but when I installed the activeadmin gem I had a problem when accessing /admin/ and received the following error on /admin/login (I was redirected, but this is what I saw on the page:) What do I do? I have done bundle update and it's not fixed it. Here's the partial error message: Sprockets::FileNotFound in Active_admin/devise/sessions#new Showing /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activeadmin->0.6.0/app/views/layouts/active_admin_logged_out

Rails - default value in text_field but only for new_record?

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: On a Content model have an attribute named slug . When creating a new record, I want to use a helper to populate this field, but on an existing record I want to use the value from the database. Currently I have: <% if @content.new_record? %> <%= f.text_field :slug, :value => "#{generate_slug(6)}" %> <% else %> <%= f.text_field :slug %> <% end %> But that seems a bit verbose. Is this the best way, or is there no other way? (Rails newb just trying to find the "Rails way" on issues I'm unsure of) Edit I should note that the helper is currently

SASS, Rails 3.1: Loading stylesheets in vendor/assets

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm using SASS to load stylesheets in a Rails 3.1(sass-rails 3.1) app. For example, sass partials in app/assets/stylesheets are loaded using @import in application.sass - @import "pages/common" @import "pages/**/*" @import "jquery-ui.css" Now, I also want to load vendor/assets/stylesheets . Note that I'm not using require vendor , as @import pages/* seems to be the sass recommended way of doing it. Files here will be css , and not sass or scss . I cannot use @import ../../../vendor/assets/stylesheets/* as it works only for sass and

Like button Ajax in Ruby on Rails

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a Ruby on Rails project with a model User and a model Content , among others. I wanted to make possible for a user to "like" a content, and I've done that with the acts_as_votable gem. At the moment, the liking system is working but I'm refreshing the page every time the like button (link_to) is pressed. I'd like to do this using Ajax, in order to update the button and the likes counter without the need to refresh the page. In my Content -> Show view, this is what I have: <% if user_signed_in ? %> <% if current_user . liked

Rails emits warning: “Rack::File headers parameter replaces cache_control after Rack 1.5”

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've recently upgraded my Rails to v3.2. The server starts and works, however I'm noticing the following warning: Rack::File headers parameter replaces cache_control after Rack 1.5. In my development.rb I have the following configuration for cache control: config.static_cache_control = "public, max-age=36000" What does the warning mean and what should I do to address it? 回答1: The warning is caused by a call from within Rails itself . The warning has been fixed in Rails 3.2.13 . 回答2: You have to upgrade Rake file. This issue occurred in Rails

Rails Bootstrap how to format form_for (width grid collapses)

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to make a form with bootstrap-sass. I need to find the optimal configuration of bootstrap classes to make it look nice. It is not showing up the way I expect, specifically when the browser width is smaller than a certain size the spaces between labels and form fields collapse and it doesn't look good anymore. It would be ok if it only happens on small width, but that's not the case. I would really appreciate some help with this, really, what is the best way to format the form-horizontal with bootstrap? Here's my code: <form class=

Style Rails collection_check_boxes

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I been trying to apply some CSS classes to collection_check_boxes but I can't get it to work. Right now I doing this: <div class="form-group"> <%= f.collection_check_boxes(:brand_ids, Brand.all, :id, :name) do |b| %> <%= b.label { b.check_box + b.text } %> <% end %> </div> which outputs this HTML: <div class="form-group"> <label for="user_brand_ids_1"> <input id="user_brand_ids_1" name="user[brand_ids][]" type="checkbox" value="1">Brand 1 </label> <input name="user[brand_ids][]" type="hidden" value=""> </div> Instead I would like to output