ruby-on-rails-3

How to get ckeditor resources to compile and load in Rails 3.1 asset pipeline

孤街浪徒 提交于 2019-12-30 21:27:00
问题 I'm trying to use CKEditor in a Rails 3.1 app. I have the ckeditor directory in app/assets/javascripts/ckeditor/, with extraneous stuff like the uncompressed and modularized source removed. It works fine in development. In production or staging environments, ckeditor can't find it's own files: config.js, lang/en.js skins/kama/editor.css. I can see that these files are not being precompiled, which makes sense since the asset pipeline by default won't include or precompile anything that matches

how to test html attributes with rspec?

十年热恋 提交于 2019-12-30 17:57:48
问题 the html I have is generated by ruby with: <%= link_to "change", "http://gravatar.com/emails" %> which results in: <a href="http://gravatar.com/emails">change</a> but I want to ensure that the link opens in a new tab with the target="blank" attribute the rspec test looks like: it { should have_link('change', href: 'http://gravatar.com/emails', target: '_blank') } but the test still passes when I don't have the target attribute being generated. 回答1: The following works for me with capybara 1.1

How to include full-path in Rails 3 link_to statement?

天涯浪子 提交于 2019-12-30 16:27:32
问题 I am trying to put a Rails link_to statement inside a Mailer email that includes the full-path (ie - http://localhost/contacts/id/confirm). The link_to statement that I am trying works in my standard View in /pages/options, but not in the Mailer email. Here is my /pages/options Controller code: class PagesController < ApplicationController def options end end And here's the pages/options View: <div> <%= link_to "here", :controller => "contacts", :action => "confirm", :only_path => false, :id

How to include full-path in Rails 3 link_to statement?

不羁岁月 提交于 2019-12-30 16:27:04
问题 I am trying to put a Rails link_to statement inside a Mailer email that includes the full-path (ie - http://localhost/contacts/id/confirm). The link_to statement that I am trying works in my standard View in /pages/options, but not in the Mailer email. Here is my /pages/options Controller code: class PagesController < ApplicationController def options end end And here's the pages/options View: <div> <%= link_to "here", :controller => "contacts", :action => "confirm", :only_path => false, :id

Nesta CMS and Rails3 integration: adding blog to an exiting rails 3 application

元气小坏坏 提交于 2019-12-30 15:00:15
问题 I'm adding nesta (0.9.8) cms, to an existing Rails 3.0.10 application. I get the blog up and running but not the layout/stylesheets. What i did until now is : 1. inside rails app main root, add gem 'nesta', gem 'sass' and run 'bundle' 2. run "nesta new nesta-blog" 3. edit config.ru like following : require ::File.expand_path('../config/environment', __FILE__) map "/" do run MyRails3App::Application end require 'nesta/env' require 'nesta/app' Nesta::App.root = ::File.expand_path('./nesta-blog'

Add paperclip url to json

你离开我真会死。 提交于 2019-12-30 14:24:33
问题 Normally in html we will use Model.field.url(:thumb) inside image tag, How to do it on json, especially with hash_secret. 回答1: In your model add the following to get the url (I believe this also works with hashing): def photo_url_thumb photo.url(:thumb) end And then you can output json like this: format.json { render :json => @model.photo_url_thumb } 回答2: In case of this being helpful to anyone, i find out a nice way to do this: class MyModel < ActiveRecord::Base has_attached_file :avatar,

Ruby on rails - pagination on search result

爷,独闯天下 提交于 2019-12-30 13:54:49
问题 I have 2 models, Post and Location, where location has_many posts and post belongs_to location. The search works fine, and the pagination works fine too except the total_entries. It shows more than 10 entries in the result View search.html: <%= form_tag search_posts_path, :method => 'get' do %> <p> <%= text_field_tag :title, params[:title] %> <%= text_field_tag :company, params[:company] %> <%= select_tag :location_id, options_from_collection_for_select(Location.all, :id, :name, params[

Why does this unused self.hash method cause a “can't convert String into Integer” error?

好久不见. 提交于 2019-12-30 13:37:34
问题 I am running through the Lynda Rails 3 tutorial. At one point, in a controller called access_controller, we call a method from a model called AdminUser. The original call was: authorized_user = AdminUser.authenticate(params[:username], params[:password]) When I run rails server, open up the browser, and access the appropriate view, I get the error: TypeError, can't convert String into Integer This same question has been asked twice before. The first time, the asker says the problem resolved

Why does this unused self.hash method cause a “can't convert String into Integer” error?

落花浮王杯 提交于 2019-12-30 13:36:10
问题 I am running through the Lynda Rails 3 tutorial. At one point, in a controller called access_controller, we call a method from a model called AdminUser. The original call was: authorized_user = AdminUser.authenticate(params[:username], params[:password]) When I run rails server, open up the browser, and access the appropriate view, I get the error: TypeError, can't convert String into Integer This same question has been asked twice before. The first time, the asker says the problem resolved

Scheduling tasks with rails

心不动则不痛 提交于 2019-12-30 13:29:20
问题 I have been going over rails scheduling tasks options and stumbled upon this piece of code from whenever. case @environment when 'production' every 1.day, :at => "#{Time.parse('12:00 A').getlocal.strftime("%H:%M")}" do runner "Company.send_later(:create_daily_stories!)" end when 'staging' every 15.minutes do command "thinking_sphinx_searchd reindex" end end I am fairly new to ruby and I dont quite understand what "Company" here stands for. In other words say i want to send an email out to