routes

Rails 3 how do I use link_to to change the value of a boolean in the db?

邮差的信 提交于 2019-12-20 09:40:09
问题 I'm trying to create a simple link that will allow an admin to approve a user on my website quite similar to what this guy was trying : In Rails 3 how do I use button_to to change the value of a boolean? Here's how it was supposed to work : Admin clicks the link to approve a user The link calls the activate function in UsersController The active function calls that users model the user model updates the approved attribute to true and saves it and here's how I was going to do it in my users

AngularJS: Read route param from within controller

喜你入骨 提交于 2019-12-20 09:39:54
问题 How can a parameter from an URL be read within an AngularJS controller? Let's say I have an URL like http://localhost/var/:value and I want the value to be stored in a variable within the controller for the /var/:value URL. I have tried using $routeParams.value and $route.current.params.value but $routeParams is undefined at the beginning and $route doesn't work. 回答1: The problem is that you probably inject $routeParams or $route in a controller that is run before a route change has occurred,

How to rename the default identifier param “id” in Rails' map.resources()?

☆樱花仙子☆ 提交于 2019-12-20 09:38:44
问题 I like all the default routes that are generated by Rail's map.resources . But, there are cases where I would like to use a non-numeric identifier in my routes. For example, If have a nested route consist of users and their articles, a standard route could be written as such: map.resources :users, :has_many => [:articles] # => e.g. '/users/:id/articles/:id' However, there are many advantages / reasons not to use the default numerical identifier generated by Rails. Is there a way to replace

Redirecting issues when user cannot sign in using Devise

此生再无相见时 提交于 2019-12-20 09:06:05
问题 In my application I authenticate users using Devise and I noticed that you can change the page that one is redirected to if the sign in fails. On the wiki I found the following example: class CustomFailure < Devise::FailureApp def redirect_url new_user_session_url(:subdomain => 'secure') end # You need to override respond to eliminate recall def respond if http_auth? http_auth else redirect end end end Following this example I created my own CustomFailure class(custom_failure.rb) and placed

Express.js or angular for handling routes in a MEAN application?

孤街醉人 提交于 2019-12-20 08:32:19
问题 I am totally new to everything Nodejs/express/angular, and I just ran into a question that bothers me. When you have a MEAN stack, it seems that routes can be handled by both Express.js and Angular . Angular : For instance, if I define a route in Angular, I can do it like this: var app = angular.module("app", []).config(function($routeProvider) { $routeProvider.when('/login', { templateUrl: '/templates/login.html', controller: 'LoginController' }); $routeProvider.when('/front', { templateUrl:

Compojure routes with different middleware

北战南征 提交于 2019-12-20 08:27:58
问题 I'm currently writing an API in Clojure using Compojure (and Ring and associated middleware). I'm trying to apply different authentication code depending on the route. Consider the following code: (defroutes public-routes (GET "/public-endpoint" [] ("PUBLIC ENDPOINT"))) (defroutes user-routes (GET "/user-endpoint1" [] ("USER ENDPOINT 1")) (GET "/user-endpoint2" [] ("USER ENDPOINT 1"))) (defroutes admin-routes (GET "/admin-endpoint" [] ("ADMIN ENDPOINT"))) (def app (handler/api (routes public

codeigniter routes is not working

你。 提交于 2019-12-20 07:36:23
问题 I have the following problem with CodeIgniter. I'm trying to setup a menu, and using route config to load the proper content but from some reason it's not working. I have CodeIgniter setup under: http://localhost/new/CodeIgniter/ My config file looks like this: $config['base_url'] = 'http://localhost/new/CodeIgniter/'; $config['index_page'] = ''; My route config looks like this: $route['default_controller'] = 'Home/home'; $route['404_override'] = ''; $route['home'] = 'Home/home'; $route[

Cakephp routes prefix

三世轮回 提交于 2019-12-20 06:09:01
问题 I have 3 diferent layouts for my application related to diferent parts of content. I vould like to define my url-s so they would have the part in the begining ex. "mypage.com/part1/controller/...". I don't know how to change routes to make this possible. P.S. I don't want ordinary prefix routing where names of my controller actions would have changed. 回答1: read below url For CakePHP 2.x http://book.cakephp.org/2.0/en/development/routing.html#prefix-routing For CakePHP 1.x http://bakery

How to solve route not defined in laravel 5.3?

。_饼干妹妹 提交于 2019-12-20 05:39:21
问题 My controller code is like this : public function store(CreateUserRequest $request) { $input = $request->all(); $user = $this->userRepository->create($input); Flash::success('User saved successfully.'); return redirect(route('user.index.'.$input['year'])); } There is exist error like this : InvalidArgumentException in UrlGenerator.php line 314: Route [users.index.2016] not defined. When error, the url look like this : http://localhost/mysystem/public/users My routes\web.php is like this :

nested namespace route going to wrong controller

瘦欲@ 提交于 2019-12-20 05:17:12
问题 Using Rails 3.0.7, I'm creating an API for our app, and I have this setup: routes.rb namespace :api do namespace :v1 do match "connect" => "users#login", :via => :post match "disconnect" => "users#logout", :via => :post resources :users match "users/:id/foos" => "foos#list", :via => :get match "users/:id" => "users#update", :via => :put match "foos/:id/bars" => "bars#list_by_foo", :via => :get match "foos/:id" => "foos#show", :via => :get, :constraints => { :id => /\d+/ } match "bars/:id" =>