controller

Magento: Extending Customer Account Controller to add actions to the forgot password steps

跟風遠走 提交于 2019-12-06 06:00:40
问题 We are trying to add a couple of actions to the AccountController to add another action after the forgotpasswordpost action. The problem is if we add the action to the preDispatch logict to make sure you don't have to be logged in it still redirects back to the login page. public function preDispatch() { // a brute-force protection here would be nice parent::preDispatch(); if (!$this->getRequest()->isDispatched()) { return; } $action = $this->getRequest()->getActionName(); if (!preg_match('/^

Grails controllers repeated code for all actions

主宰稳场 提交于 2019-12-06 05:34:56
Imagine this controller: class exampleController{ def action1 = {} def action2 = {} def action3 = {} def action4 = {} def action5 = {} } I want to be able to return in all the action in this controller the same params. Imagining this: def user = session.user [user: user] Is there any way of doing this, besides writing all the same code on all the actions? The session.user return params is just an example. I don't wanna really return it. A simple solution is to put this code in a method and call it from each action class exampleController{ def action1 = {getModel()} def action2 = {getModel()}

Devise : Sign in from a controller

人走茶凉 提交于 2019-12-06 05:15:18
I need to sign in fron non-devise controller. I found this link from devise wiki, but I get error : wrong number of arguments (2 for 0) I did exactly like in the link. What went wrong? Thanks My code : sign_in(:site, Site.find(params["si"])) sign_in(:user, User.find(params[:id]) If you do a binding.pry after you'll see that current_user is set. For some reason, doing a redirect after this will make current_user nil. That's why I set something in the session like this and then redirect, and then check if that session id is set and then use it to do the above code: session[:new_user_id] = params

Render a .js controller request as html

情到浓时终转凉″ 提交于 2019-12-06 05:11:36
问题 I have a before_filter in my Rails app that sends users to login_url if they are logged out when they submit a request (in either html or js format). I would like my format.js to produce an identical result to format.html , in the following case to render the view with the 'notice' layout. How can I do this? respond_to do |format| format.js format.html{ render :layout => "notice" } end 回答1: you can force the usable formats like this : respond_to do |format| format.js { render :layout =>

How can I remove callbacks inserted by vendor code?

早过忘川 提交于 2019-12-06 05:07:58
A gem I am using inserts an after_save callback that I would like to remove. It seems to me it would be cleaner to delete a symbol from an array than to fix the problem with a monkeypatch. How can I access the array of callbacks? class UserSession < Authlogic::Session::Base # Don't use cookie AuthLogic behaviour skip_callback :persist, :persist_by_cookie skip_callback :after_save, :save_cookie skip_callback :after_destroy, :destroy_cookie end the after_save array is accessible via Model.after_save , it is an array of ActiveSupport::Callbacks::Callback objects. You could run this from within

Wicked gem Rails - How to create a new object

♀尐吖头ヾ 提交于 2019-12-06 05:07:48
问题 The Building Partial Objects Step by Step page on the Wicked Gem Wiki explains how to create an object step by step with wicked . But how do I have to create a new Product object? Do i have to do that in the new action in the ProductsController ? And where do i have to redirect to ? 回答1: The following statement is given in the Building Partial Objects Step by Step page. This also means to get to the create action we don't have a product_id yet so we can either create this object in another

Implement your own object binder for Route parameter of some object type in Play scala

社会主义新天地 提交于 2019-12-06 04:53:11
问题 Well, I want to replace my String param from the following Play scala Route into my own object, say "MyObject" From GET /api/:id controllers.MyController.get(id: String) To GET /api/:id controllers.MyController.get(id: MyOwnObject) Any idea on how to do this would be appreciated. 回答1: Use PathBindable to bind parameters from path rather than from query. Sample implementation for binding ids from path separated by comma (no error handling): public class CommaSeparatedIds implements

How can I add a Dialog View Controller as a Subview to a UIView or Vice Versa?

十年热恋 提交于 2019-12-06 04:45:35
问题 I have looked around the web for some time looking for any resources on this topic and have come up with nothing that solves my dilemma. I have a dialog view controller and its root is simply displaying a list of strings similar to how the iphone music song scrollable view is laid out. What I need is a subview located at the top of the screen and the scrollable DVC below it. I need to the top view to be always in view while the user can scroll through the root element because the top view

Custom page in Prestashop 1.6 without CMS

吃可爱长大的小学妹 提交于 2019-12-06 04:45:02
问题 I'm currently creating a customized page based on Bootstrap so I cannot pass through the CMS. I created a file Mypage.php that I put at the Prestahop root containing this code : <?php require(dirname(__FILE__).'/config/config.inc.php'); ControllerFactory::getController('MypageController')->run(); ?> Then I created a controller MypageController.php containing this code in override/controllers/front : class MypageControllerCore extends FrontController { public $php_self = 'Mypage.php'; public

Architecting ASP.net MVC App to use repositories and services

僤鯓⒐⒋嵵緔 提交于 2019-12-06 03:47:15
I recently started reading about ASP.net MVC and after getting excited about the concept, i started to migrate all my webform project to MVC but i am having a hard time keeping my controller skinny even after following all the good advices out there (or maybe i just don't get it ... ). The website i deal with has Articles, Videos, Quotes ... and each of these entities have categories, comments, images that can be associated with it. I am using Linq to sql for database operations and for each of these Entities, i have a Repository, and for each repository, i create a service to be used in the