ruby-on-rails-3.2

Error loading media: File could not be played error in jw_player rails

ε祈祈猫儿з 提交于 2019-11-28 06:20:57
问题 I am using the below mentioned code to play a video from my local disk. But its not working instead of that it's throwing Error loading media: File could not be played error error. I have mentioned the code below. <%= jwplayer_assets %> <%= jwplayer ({:file => "/home/user/Downloads/digital.mp4", :image => "/home/user/Downloads/Retreats_21.jpg"}) %> I'am new to this jw_player. so please help me to solve this issue. Thanks in advance.. 回答1: Download jwplayer from http://www.longtailvideo.com/jw

TinyMCE 4 links plugin modal in not editable

瘦欲@ 提交于 2019-11-28 05:46:04
I am using tinyMCE4 editor inside a Boostrap modal dialog. when I clicked on link icon it opens a new modal dialog box, It displayed fine but the input areas are not editable. <div id="editing" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <form> <label> <span>Description</span> <div id="description"></div> </label> <form> </div> <script> tinymce.init({ selector: 'div#description', inline: false, theme : "modern", schema: "html5", add_unload_trigger: false, statusbar: false, plugins: "link", toolbar: "link | undo redo", menubar: false })

How to set a background image in rails from css?

主宰稳场 提交于 2019-11-28 05:13:55
I am using rails 3.2 and i have to set a background for one of the page and i have tried many ways and nothing went right, so looking for some good help. I have tried background: url(<%= asset_path 'background.jpg' %>) background: url("public/background.jpg"); background-image:url('/assets/images/background.jpg') and nothing worked. Please help me. Rajarshi Das In your CSS: background-image: url(background.jpg); or background-image: url(/assets/background.jpg); In environments/production.rb : # Disable Rails's static asset server (Apache or nginx will already do this) config.serve_static

How to require a ruby file from another directory

蹲街弑〆低调 提交于 2019-11-28 04:57:14
I am trying to require a rake file that I have created inside another file I have. These two files are inside two different directories. I have require at the top of my first file with the name of the second file inside the quotes after the require. It is telling me that it can't load such file. Does that mean because its in different directory it can't find it? I tried sticking in the full path to the second file but it still can't load the file. Does anyone know how I can load the second file into the first? Thanks in advance require will search for files in only a set of locations referred

find(:first) and find(:all) are deprecated

ぃ、小莉子 提交于 2019-11-28 03:54:01
问题 I am using RubyMine with rails 3.2.12 and I am getting following deprecated warning in my IDE. Any Idea How can I solve this deprecated warning? find(:first) and find(:all) are deprecated in favour of first and all methods. Support will be removed from rails 3.2. 回答1: I changed my answer after @keithepley comment #Post.find(:all, :conditions => { :approved => true }) Post.where(:approved => true).all #Post.find(:first, :conditions => { :approved => true }) Post.where(:approved => true).first

Rendering JSON in controller

爱⌒轻易说出口 提交于 2019-11-28 02:58:39
I was reading a book and in a chapter about Controllers when it talks about rendering stuff, for JSON it has an example like this but doesn't go in to details so I couldn't figure out the bigger picture that this example fits in: render :json => @projects, :include => tasks And also some example with JSONP using it with callback functions: render :json => @record, :callback => 'updateRecordDisplay' Can someone explain these? You'll normally be returning JSON either because: A) You are building part / all of your application as a Single Page Application (SPA) and you need your client-side

save_and_open_page (capybara / launchy) stopped working in a project - error

坚强是说给别人听的谎言 提交于 2019-11-28 01:59:23
问题 Trying to debug a section of specs that I cannot get to work when merging Rails two projects. I have deleted my Gemfile.lock and re-installed from scratch, I have run bundle update on specific gems, and the whole lot but am getting an error when I try to use in my request spec save_and_open_page railsdev$ bin/rspec spec/requests/authentication_pages_spec.rb No DRb server is running. Running in local process instead ... /Users/rb/Repos/Genie/spec/requests/authentication_pages_spec.rb:33:in

301 Moved Permanently after S3 uploading

孤街浪徒 提交于 2019-11-27 23:41:34
问题 Im trying to upload images to S3 on Ruby on Rails using carrierwave and fog gems, images are uploaded correctly but when I try tu save the model containing information about the image that was just uploaded Im getting this error: Excon::Errors::MovedPermanently in UserController#show app/models/user.rb:46:in `process_image_with_key' app/controllers/user_controller.rb:12:in `show' <Excon::Response:0x007f97846a3c18 @body="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code

How to initialize an ActiveRecord with values in Rails?

微笑、不失礼 提交于 2019-11-27 23:18:29
问题 In plain java I'd use: public User(String name, String email) { this.name = name; this.email = f(email); this.admin = false; } However, I couldn't find a simple standard way to do in rails (3.2.3), with ActiveRecords. 1. override initialize def initialize(attributes = {}, options = {}) @name = attributes[:name] @email = f(attributes[:email]) @admin = false end but it might be missed when creating a record from the DB 2. using the after_initialize callback by overriding it: def after

Reserved names with ActiveRecord models

心已入冬 提交于 2019-11-27 20:21:50
I take naming pretty seriously, so I think pretty hard about good names for my ActiveRecord models. However, I frequently come up with a name and it has some conflict with a reserved name, either in the database or Ruby or Rails. Model or field names like set or group . Sometimes the issue isn't immediately apparent either. Is there a list somewhere of names we can't use in our model names and a list for field names? Here's a couple of resources to get you started: Rails reserved words . This one seems to be fairly up to date, last updated on Feb 2010. It even goes beyond rails and lists some