ruby-on-rails-3

How do I convert an existing Rails 3 Application into an Engine?

房东的猫 提交于 2019-12-31 08:47:10
问题 How can I convert the Forum application I've been developing into a Rails Engine, so that it may be embedded inside other applications? What should I add, keep, or remove? Should I offer a way to integrate the models? How do I set up routes and user configuration? How do I package it into a Gem? What should I watch out for? After reading the articles and the documentation, I managed to narrow down my questions: Should I namespace the models? That is, should I keep them in my Engine's module

rails - application.css asset not found in production mode

柔情痞子 提交于 2019-12-31 08:45:48
问题 I'm upgrading an application to use the asset pipeline. I've got the css assets compiling into an application css file but they not being found when I run the application in production mode with RAILS_ENV=production bundle exec rails s and I visit any page I get the correct output from the database but no styling and the log shows: ActionController::RoutingError (No route matches [GET] "/assets/default.scss-1a27c...f07c.css"): Even though that file exists in public/assets $ ls public/assets

rails - application.css asset not found in production mode

萝らか妹 提交于 2019-12-31 08:45:12
问题 I'm upgrading an application to use the asset pipeline. I've got the css assets compiling into an application css file but they not being found when I run the application in production mode with RAILS_ENV=production bundle exec rails s and I visit any page I get the correct output from the database but no styling and the log shows: ActionController::RoutingError (No route matches [GET] "/assets/default.scss-1a27c...f07c.css"): Even though that file exists in public/assets $ ls public/assets

Rails 3.1 + Paperclip + jQuery fileupload

ⅰ亾dé卋堺 提交于 2019-12-31 08:39:11
问题 I've been looking for a way to set up Ruby on Rails 3.1 with Paperclip and jQuery fileupload. Looking at a tutorial at jQuery fileupload page I got the system set up but I can't find a way to make paperclip process the uploaded file. Here's what I have (in short): # model has_attached_file :photo ... # view = form_for @user, :html => {:multipart => true} do |f| f.file_field :photo, :multiple => true f.submit # controller def create @user = User.new params[:user] if @user.save render :json =>

What does this Rails Engine code mean: config.to_prepare &method(:activate).to_proc

▼魔方 西西 提交于 2019-12-31 08:39:11
问题 I'm working with Spree, which uses Rails engines extensively. A common pattern I find is this. However I have trouble understanding this code. class Engine < Rails::Engine def self.activate ... end config.to_prepare &method(:activate).to_proc end What does .to_prepare do What does the &method operator do? What is the overall effect of the code? Many Thanks! 回答1: &method(:activate).to_proc This is best consumed one item at a time. (It should be noted that this portion of the code is 100% non

How to implement a web widget with OAuth 2.0

纵然是瞬间 提交于 2019-12-31 08:38:27
问题 I want to create a web widget that will display information from my site. The widget will be included in the client's website HTML using JavaScript, and should only be usable for my clients -- web sites that were registered at my site. The information in the widget should be specific to the user who is currently visiting the client's site. So, I need to authenticate both the client (website owner) and the resource owner (website visitor). This seems to map nicely to OAuth 2.0, but I couldn't

Append/prepend bootstrap icons with simple_form

做~自己de王妃 提交于 2019-12-31 08:36:06
问题 Twitter Bootstrap icons are pretty deadly seen here. Look at the bottom right hand corner of that section. See that email with an icon prepended? That is what I want to do. I want to make simple_form and boostrap play nicely. Here's what I've found that will prepend the icon to the input: = f.input :email, :wrapper => :append do = f.input_field :email <span class="add-on"><i class="icon-envelope"></i></span> But it isn't flush (that could be fixed by changing offsets in CSS) and it's pretty

Paperclip: How to store a picture in a Rails console?

ぐ巨炮叔叔 提交于 2019-12-31 08:29:35
问题 I tried storing a local image in a rails console. Because I have many pictures in my local storage (I use crawler to download tons of pictures), I want to store them into a database, with the benefit of paperclip to do some image job, like thumbnail etc. If I use a webpage to save new pictures to database one by one, it will cost a lot of time. So I want to find a way in rails console (some code) that can batch save-picture-into-database. 回答1: To further clarify @andrea's answer:

Paperclip: How to store a picture in a Rails console?

邮差的信 提交于 2019-12-31 08:29:12
问题 I tried storing a local image in a rails console. Because I have many pictures in my local storage (I use crawler to download tons of pictures), I want to store them into a database, with the benefit of paperclip to do some image job, like thumbnail etc. If I use a webpage to save new pictures to database one by one, it will cost a lot of time. So I want to find a way in rails console (some code) that can batch save-picture-into-database. 回答1: To further clarify @andrea's answer:

Converting a regular Youtube 'link' into an embedded video

拈花ヽ惹草 提交于 2019-12-31 08:14:52
问题 My goal: I am trying to allow users to embed a link to a Youtube video in my site, while giving me control over the player's settings. I would like to do this by only asking the user to supply the link (not the entire embed code), from where I can somehow paste that link into the embed code. I've tried doing a simple substitution with a few Youtube links ( http://youtu.be/... ) but they don't work, saying 'movie not loaded'. Is there a dependable way to do this? 回答1: I do this quite often for