controller

Categories of controllers in MVC Routing? (Duplicate Controller names in separate Namespaces)

冷暖自知 提交于 2019-12-04 13:44:58
I'm looking for some examples or samples of routing for the following sort of scenario: The general example of doing things is: {controller}/{action}/{id} So in the scenario of doing a product search for a store you'd have: public class ProductsController: Controller { public ActionResult Search(string id) // id being the search string { ... } } Say you had a few stores to do this and you wanted that consistently, is there any way to then have: {category}/{controller}/{action}/{id} So that you could have a particular search for a particular store, but use a different search method for a

Devise Registration form on any page

拜拜、爱过 提交于 2019-12-04 13:40:57
问题 I'm trying to allow users to sign up for the site on my home/landing page. I've duplicated the devise registration form into my landing page view- <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> <%= devise_error_messages! %> <div><%= f.label :first_name %><br /> <%= f.text_field :first_name %></div> <div><%= f.label :last_name %><br /> <%= f.text_field :last_name %></div> <div><%= f.label :profile_name %><br /> <%= f.text_field :profile_name %>

Laravel: Controller does not exist

房东的猫 提交于 2019-12-04 13:39:32
问题 I added new controller in /app/controllers/admin/ folder and added the route in /app/routes.php file as well. Then i run the following command to autoload them php artisan dump-autoload I got the following error Mcrypt PHP extension required. I followed instruction given at https://askubuntu.com/questions/460837/mcrypt-extension-is-missing-in-14-04-server-for-mysql and able to resolve the mcrypt issue. After that i run the php artisan dump-autoload command but still getting following error {

Rspec / Capybara: Testing if a controller method is called

戏子无情 提交于 2019-12-04 13:36:44
问题 Given I set up a HomeController with an index action class HomeController < ApplicationController def index @users = User.all end end and routed to it via the root path, root :to => "home#index" why does this request spec fail it 'should called the home#index action' do HomeController.should_receive(:index) visit root_path end with the following message Failure/Error: HomeController.should_receive(:index) (<HomeController (class)>).index(any args) expected: 1 time received: 0 times ? Is it

Rails: Dividing up a single database between multiple subdomains

两盒软妹~` 提交于 2019-12-04 12:53:32
I'm relatively new to Rails, and here is my situation: I'm building an inventory management app with rails to help three separate branches of a company manage their own product inventory. Each of these three branches are keeping track of the same products, use the same data models, but are managed separately. My plan is to build a single app using a single database, but one that keeps track of the inventory in all three branches. My plan is to have something like this: branch1.inventoryapp.com branch2.inventoryapp.com branch3.inventoryapp.com Each subdomain will lead to the same interface with

Java Jinput: rescan / reload controllers

早过忘川 提交于 2019-12-04 12:43:37
I am using java jinput library to read data from joypad, and I have trouble reloading Controllers , I use this to load them: public Controller[] findStickControllers() { ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment(); Controller[] cs = ce.getControllers(); System.out.println(cs.length); //test ArrayList<Controller> sel = new ArrayList<>(); for (Controller c: cs) { if(c.getType() == Type.STICK) { sel.add(c); } } return sel.toArray(new Controller[]{}); } This works fine, but if I disconnect my controller, calling this will find it again, and vice versa (connecting it

Rails 2 to Rails 3, method verification in controllers gone?

雨燕双飞 提交于 2019-12-04 11:47:13
问题 Coming from rails 2, most of my controllers would have these lines: verify :method => :post, :only => :create, :render => {:text => '405 HTTP POST required', :status => 405}, :add_headers => {'Allow' => 'POST'} verify :method => :put, :only => :update, :render => {:text => '405 HTTP PUT required', :status => 405}, :add_headers => {'Allow' => 'PUT'} verify :method => :delete, :only => :destroy, :render => {:text => '405 HTTP DELETE required', :status => 405}, :add_headers => {'Allow' =>

angular multiple routes sharing one controller

ぐ巨炮叔叔 提交于 2019-12-04 11:46:46
I'm not sure if I'm approaching this correctly but I'm building an ecommerce site - part of the site has 6 different product grid pages, each of which can use the same view: <ul class="products row"> <li class="product thumbnail col-1 grid" ng-repeat="whisky in whiskies | orderBy: sort"> <p class="picture"> <a ng-href="#/json/{{whisky.id}}"><img ng-src="images/scotch/{{whisky.imageUrl}}" alt="{{whisky.name}}"/></a> </p> <div class="desc"> <h2>{{whisky.name}}</h2> <p class="price"><span>£{{whisky.price}}</span></p> </div> <div class="actions"> <button class="add-to-basket btn btn-primary btn

MVC - do I need to use Controller in the View?

℡╲_俬逩灬. 提交于 2019-12-04 11:44:28
问题 As I know in the standard implementation of the MVC we pass Controller and Model to the View But Im a little bit disagree with this idea. I dont want my view to know about both controller and model (oh no. maybe sometimes view needs model, but I'm sure that he can live without knowledge of controller) In my opinion Controller should manage View and Model, and Model doesn't need to know about controller and view; view doesnt need to know controller (I dont exclude model because some

PHP Slim Framework Create Controller

戏子无情 提交于 2019-12-04 11:43:20
I am creating an API using the Slim framework. Currently I use a single file to create the route and pass a closure to it: $app->get('/', function($req, $resp){ //Code... }) But I realise that my file has grown rapidly. What I want to do is use controllers instead, so I will have a controller class and just pass the instance/static methods to the route, like below class HomeController { public static function index($req, $resp){} } and then pass the function to the route $app->get('/', HomeController::index); I tried this, but it does not work, and I wonder if there is a way I can use it to