ruby-on-rails-3

error facing while cropping photo using Paperclip in Rails 3

孤人 提交于 2020-01-04 06:12:35
问题 Hi i am trying to crop photo using paperclip and imagemagick. I am facing some error while cropping photo. following is the error stack: ?[32mCommand?[0m :: convert "C:/Users/Anand/AppData/Local/Temp/120120924-3568-tx 2bxy.jpg[0]" -crop 103x103+0+0 -auto-orient "C:/Users/Anand/AppData/Local/Temp/1 20120924-3568-tx2bxy20120924-3568-16dij9c" ?[32mCommand?[0m :: file -b --mime "C:/Users/Anand/AppData/Local/Temp/120120924- 3568-tx2bxy20120924-3568-16dij9c" [paperclip] Error while determining

error facing while cropping photo using Paperclip in Rails 3

ぐ巨炮叔叔 提交于 2020-01-04 06:12:26
问题 Hi i am trying to crop photo using paperclip and imagemagick. I am facing some error while cropping photo. following is the error stack: ?[32mCommand?[0m :: convert "C:/Users/Anand/AppData/Local/Temp/120120924-3568-tx 2bxy.jpg[0]" -crop 103x103+0+0 -auto-orient "C:/Users/Anand/AppData/Local/Temp/1 20120924-3568-tx2bxy20120924-3568-16dij9c" ?[32mCommand?[0m :: file -b --mime "C:/Users/Anand/AppData/Local/Temp/120120924- 3568-tx2bxy20120924-3568-16dij9c" [paperclip] Error while determining

scss.erb ruby code not executing

本秂侑毒 提交于 2020-01-04 05:54:17
问题 I am trying to load a background image which is stored on Rackspace's CloudFiles in my Stylesheet file. I used Fog & CarrierWave to upload the image file and to call the file. I keep on getting this error: Invalid CSS after "...und-image: url(": expected ")", was "<%= design.main..." preview.css.scss.erb: html{ background-image: url(<%= design.main_image_url.to_s %>); } Update: I rephrase my question and I got an answer from here What I should have ask was "How to pass an instance variable to

Minimagick error during upload “composite -compose Over -gravity North”

霸气de小男生 提交于 2020-01-04 05:46:31
问题 I am trying to upload an image by gem "carrierwave", "~> 1.1.0" and gem "mini_magick", "~> 4.7.0" to upload image. I am getting this error. I am using this code to upload image. MiniMagick::Tool::Convert.new do |i| i.size "#{image_width.ceil}x#{watermarked_image_height.ceil}" i.gravity "center" i.xc "white" i << temp_image_path end @_watermarked_image = MiniMagick::Image.open(temp_image_path) @_watermarked_image = @_watermarked_image.composite(source_image, "jpg") do |c| c.compose "Over" c

Call a method on a variable where the method name is in another variable

点点圈 提交于 2020-01-04 05:44:54
问题 <% @labels.each do |label| %> <input type="text" name="<%=label.name%>" value="<%=@car.(label.related_to) %>" class="big-font" style="width: <%=label.width%>px; top: <%=label.y_coor%>px; left: <%=label.x_coor%>px;" /> <% end %> Hello guys, I'm new to rails so this should be a fairly easy question to answer. The issue is here: <%=@car.(label.related_to) %> . label.related_to holds the string "make". I'm trying to get it to do this pretty much: @car.make Any idea guys? Thanks, Alain 回答1: Use

How to stub a function IN a Helper during test

旧时模样 提交于 2020-01-04 05:31:07
问题 Take a look at this helper function: def show_welcome_banner? (controller_name == 'competition' && action_name == 'index') || (controller_name == 'submissions' && action_name == 'show') end It expects the controller_name and action_name functions to be defined. I tried to use this in my RSpec matcher: describe PageHelper do it "should know when the welcome banner is to be shown" do helper.stub!(:controller_name).and_return('index') show_welcome_banner?.should == false end end But this won't

sunspot return all results for a model

巧了我就是萌 提交于 2020-01-04 05:19:12
问题 I have in my controller this: def boards @user = User.find_by_slug(params[:id]) @search = @user.boards.solr_search do |s| s.fulltext params[:search] s.keywords params[:search] s.order_by :created_at, :desc s.paginate :page => params[:page], :per_page => 1 end @boards = @search.results respond_to do |format| format.html { render :layout => nil}# panel.html.erb format.json { render json: @boards } format.js end end In my view: <table id="body_object"> <% for board in @boards %> <tr class=

Rails 3: Best practices for saving models

拟墨画扇 提交于 2020-01-04 04:43:47
问题 When should I save my models in rails? and who should be responsible for calling save, the model itself, or the caller? Lets say I have (public)methods like udpate_points , update_level , etc. in my user model. There are 2 options: The model/method is responsible for calling save . So each method will just call self.save . The caller is responsible for calling save. So each method only updates the attributes but the caller calls user.save when it's done with the user. The tradeoffs are fairly

assets:precompile - permission denied - only on one computer

穿精又带淫゛_ 提交于 2020-01-04 04:43:05
问题 I have a rails app project folder which is on my dropbox folder. I work on 2 computers - home pc and a laptop (both win 7) If I do bundle exec rake assets:precompile on the pc it works fine and I see the line C:/Ruby193/bin/ruby.exe C:/Ruby193/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets mkdir -p H:/My Dropbox/project/public/assets cp -r C:/Ruby193/lib/ruby/gems/1.9.1/gems/tinymce-rails-3.5.7.1/vendor/assets/javascripts/tinymce H:/My Dropbox/project/public/assets

Factory Girl with has many relationship (and a protected attribute)

我是研究僧i 提交于 2020-01-04 04:02:44
问题 I have this kind of relation: class Article < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :article attr_protected :article_id end The default scenario inside controllers looks like: @article = Article.create(:title => "foobar") @comment = @article.comments.create(:content => "w00t") I had tried to write those factories: Factory.define :article do |f| f.title "Hello, world" end Factory.define :comment do |f| f.content "Awesome!" f.association