ruby-on-rails

TinyMCE and Bootstrap Modals — Works only one time

大城市里の小女人 提交于 2021-02-18 12:16:31
问题 I'm using Bootstrap and tinymce-rails so that I can have a nice text editor for some of my text areas. However, I'm having a modal render a form that contains a textarea and the "tinymce" class, but this modal only actually shows the TinyMCE text editor one time. Once the modal is closed and re-opened, it only looks like a regular text field. Here's the form that's being rendered: <%= form_for @paragraph_section, html: {class: "form-horizontal"} do |f| %> <div class="form-group"> <%= f.label

Rails cache expire

本小妞迷上赌 提交于 2021-02-18 10:36:07
问题 I have a rails application, in that I am using simple rails cache. My testing is as follows: Rails.cache.write('temp',Date.today,:expires_in => 60.seconds) I can read it through Rails.cache.read('temp') and Rails.cache.fetch('temp') . The problem is it doesn't expire. It will still be alive after 60 seconds. Can any one tell me what is missing here. FYI: I have declared in my development.rb as follows : config.action_controller.perform_caching = true config.cache_store = :memory_store Is

Heroku not recognized as an internal or external command (Windows)

人走茶凉 提交于 2021-02-18 08:57:06
问题 Following this heroku tutorial to launch an app on heroku. But when I use the command heroku create , it says it's not recognized. I added C:\Program Files\Heroku to my PATH. How do I fix this? 回答1: You can follow the Getting Started on Heroku with Python . My Heroku.exe PATH is in C:\Program Files\Heroku\bin . Make sure your Heroku's Path is correct. Or you can re-install the heroku. 回答2: You're probably using an old version or the deprecated package 'heroku-cli' . The new one is just called

Rails - redirect to current url without one of the GET params

ε祈祈猫儿з 提交于 2021-02-18 08:54:12
问题 I have a very simple problem in a Rails app that I can't find an elegant solution to. I have a URL like: http://www.example.com/some-path/?foo=123&baz=456 And I want to process one of the params and do a redirect to: http://www.example.com/some-path/?baz=456 I want this to work generally for any URL with param "foo", so I don't want to specify "baz" in the rewrite code. What I want is something like: redirect_to request.path, :params => request.query_parameters.except(:foo) Except that doesn

Rails 4, subdomain routing

被刻印的时光 ゝ 提交于 2021-02-18 07:22:48
问题 Trying to implement web service in rails through API sub-domain called "api". In my hosts file i added line: 127.0.0.1 api.localhost In my routes.rb i set sub-domain, where i only need index action and few manually added restful routes, through following: namespace :api, path: '', :constraints => {:subdomain => "api"} do resources :posts, only: :index do collection do get 'popular_by_day' get 'popular_by_week' end end end Also generated coresponding controller with: rails g controller api

How to internationalize content on ruby on rails?

眉间皱痕 提交于 2021-02-18 07:03:12
问题 How can I internationalize say a categories table (with a name column) into different languages. How about a products table (consisting of a name and description columns). Which is the best way to internationalize the content of these database tables using Ruby on Rails? 回答1: Have you taken a look at: http://guides.rubyonrails.org/i18n.html It describes in some detail how to internationalise your application and "provides an easy-to-use and extensible framework for translating your

undefined local variable or method `flash' for #<Devise::OmniauthCallbacksController:0x007fb5d1741e48>

你。 提交于 2021-02-18 06:41:31
问题 I am building a Rails-API using Omniauth-facebook and Devise-token-auth with Angular and ng-token-auth for the frontend. However when logging in with facebook I am presented with the error: undefined local variable or method `flash' for #<Devise::OmniauthCallbacksController:0x007fd027a51e10> It seems omniauth automatically uses flash middleware however the rails-api doesn't include this and I have been unsuccessfully disabling the use of flash with omniauth. My configuration is as below:

PostgreSQL ilike with multiple matches in Rails ActiveRecord

北城以北 提交于 2021-02-18 06:08:27
问题 I am trying to retrieve multiple records from my DB with the following query: User.where('name ilike ?','%thomas%') this works fine. Now I want to retrieve multiple records at the same time and tried this (which seems to be syntactically incorrect): User.where('name ilike any',['%thomas%','%james%','%martin%']) What am I doing wrong? So just to clarify: I want to retrieve all records that match one of the names, so its an OR statement I am looking for. 回答1: You can do it by User.where('name

PostgreSQL ilike with multiple matches in Rails ActiveRecord

ⅰ亾dé卋堺 提交于 2021-02-18 06:07:44
问题 I am trying to retrieve multiple records from my DB with the following query: User.where('name ilike ?','%thomas%') this works fine. Now I want to retrieve multiple records at the same time and tried this (which seems to be syntactically incorrect): User.where('name ilike any',['%thomas%','%james%','%martin%']) What am I doing wrong? So just to clarify: I want to retrieve all records that match one of the names, so its an OR statement I am looking for. 回答1: You can do it by User.where('name

PostgreSQL ilike with multiple matches in Rails ActiveRecord

最后都变了- 提交于 2021-02-18 06:07:33
问题 I am trying to retrieve multiple records from my DB with the following query: User.where('name ilike ?','%thomas%') this works fine. Now I want to retrieve multiple records at the same time and tried this (which seems to be syntactically incorrect): User.where('name ilike any',['%thomas%','%james%','%martin%']) What am I doing wrong? So just to clarify: I want to retrieve all records that match one of the names, so its an OR statement I am looking for. 回答1: You can do it by User.where('name