actionpack

Getting rid of DEPRECATION WARNING: env is deprecated and will be removed from Rails 5.0.

强颜欢笑 提交于 2019-12-22 06:53:23
问题 While migrating to Rails 5.0.0.beta1 I discovered lots of deprecation warning : DEPRECATION WARNING: env is deprecated and will be removed from Rails 5.0. (called from XXX at YYY) I've tried to get rid of that and try to find an alternative but found nothing in the actionpack changelog. Any ideas ? 回答1: ok, so it seems that env method has been deprecated in ActionPack by this commit. so from now on we should user request.env instead of env in our controllers and helpers. 来源: https:/

How to include respond_to when you don't inherit from ApplicationController in Rails 4?

末鹿安然 提交于 2019-12-11 03:14:51
问题 I have an API controller in a Rails 4.1.2 app that does not inherit from Application controller. I'm trying to include the respond_to method and get a method undefined error....So then I required actionpack at the top like below: require 'action_pack' class Api::V1::UsersController < Api::ApiController version 1 doorkeeper_for :all respond_to :json def show respond_with current_user.as_json(except: :password_digest) end end and I still get ActionController::RoutingError (undefined method

Rails 4.1.2 - to_param escapes slashes (and breaks app)

谁说我不能喝 提交于 2019-12-10 13:20:08
问题 I use in my app to_param to create custom URL (this custom path contains slashes): class Machine < ActiveRecord::Base def to_param MachinePrettyPath.show_path(self, cut_model_text: true) end end The thing is, that since Rails 4.1.2 behaviour changed and Rails doesn't allow to use slashes in the URL (when use custom URL), so it escapes slashes. I had such routes: Rails.application.routes.draw do scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do resources :machines, except:

What is the opposite of url_for in Rails? A function that takes a path and generates the interpreted route?

可紊 提交于 2019-12-09 16:09:59
问题 Brain's a little fried....How do I get a hash of the :controller and :action from a relative_path? This is basically the opposite of url_for. in the example below, "some_function" is the mystery function name I'm looking for...I know it's easy, just can't remember or seem to be able to find it in the docs. Like so: some_function('/posts/1/edit') => {:controller => 'posts', :action => 'edit', :id => '1'} 回答1: Rspec has a method 'params_for', which uses Action Controller's Routing Methods to

How do I require NumberHelper and make it work?

吃可爱长大的小学妹 提交于 2019-12-08 15:55:42
问题 I'm trying to write a simple Sinatra thingy but I need ActionView::Helpers::NumberHelper from action pack. http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html The question is, how do I install and use it? irb(main):001:0> require 'action_view/helpers/number_helper' irb(main):002:0> number_with_precision(1) NoMethodError: undefined method `number_with_precision' for main:Object irb(main):004:0> ActionView::Helpers::NumberHelper.number_with_precision(1) NoMethodError:

Action Pack Design and Development - am I missing something [closed]

蹲街弑〆低调 提交于 2019-12-07 08:40:33
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . The Action Pack (see here: https://partner.microsoft.com/global/40138499) seems to be incredibly good value if I am understanding it correctly. The price is $490 and if I'm understanding correctly it comes with 3x VS2010 Professional licenses, and on top of that, commercial use licenses for 10 Office 2010

Action Pack Design and Development - am I missing something [closed]

孤街醉人 提交于 2019-12-05 15:24:39
The Action Pack (see here: https://partner.microsoft.com/global/40138499 ) seems to be incredibly good value if I am understanding it correctly. The price is $490 and if I'm understanding correctly it comes with 3x VS2010 Professional licenses, and on top of that, commercial use licenses for 10 Office 2010 Professional Plus users, 1x Server 2008 R2, 1x Exchange Server, heaps of CALS. Am I missing something here? It seems to be far to cheap. There are some restrictions for the MS Action Pack: Your company must have fewer than 100 employees Your company cannot hold a MS silver or gold competency

What is the opposite of url_for in Rails? A function that takes a path and generates the interpreted route?

假装没事ソ 提交于 2019-12-04 03:17:40
Brain's a little fried....How do I get a hash of the :controller and :action from a relative_path? This is basically the opposite of url_for. in the example below, "some_function" is the mystery function name I'm looking for...I know it's easy, just can't remember or seem to be able to find it in the docs. Like so: some_function('/posts/1/edit') => {:controller => 'posts', :action => 'edit', :id => '1'} Rspec has a method 'params_for', which uses Action Controller's Routing Methods to parse paths with methods into routes. Theirs is a little more robust than this, but it boils down to: def

What approach do you take for embedding links in flash messages?

末鹿安然 提交于 2019-12-03 18:40:28
问题 The ability to have flash messages (notice, error, warning, etc) with embedded links is nice from a user interaction standpoint. However, embedding an anchor tag inside a flash message from the controller is dirty. Let's assume that a flash message like this is good for usability*: Example Flash Message Notice with an Embedded Link http://img.skitch.com/20090826-xbsa4tb3sjq4fig9nmatakthx3.png (borrowed from DailyMile.com) What tactic would you take between the controller and view to employ

What approach do you take for embedding links in flash messages?

試著忘記壹切 提交于 2019-11-30 00:11:25
The ability to have flash messages (notice, error, warning, etc) with embedded links is nice from a user interaction standpoint. However, embedding an anchor tag inside a flash message from the controller is dirty. Let's assume that a flash message like this is good for usability*: Example Flash Message Notice with an Embedded Link http://img.skitch.com/20090826-xbsa4tb3sjq4fig9nmatakthx3.png (borrowed from DailyMile.com ) What tactic would you take between the controller and view to employ something like this cleanly? Just thought I would share this, since found answer I was looking for