routes

AngularJS ngRoute direct part access

醉酒当歌 提交于 2019-12-12 06:13:18
问题 My app works fine with ngRoute, but when I'm trying to access my parts directly(from address bar), it returns just the part (without main page). How to hide these parts from a direct access? Explanation: I have a site with 2 blocks. First is a menu and second is a content (one of my route's part). Menu has links: "#/main" and "#/account". When I press on the buttons, it works fine (left menu and content). But if I change URL from localhost:8080/#/account to localhost:8080/account, it renders

Laravel Route::get using where conditions

懵懂的女人 提交于 2019-12-12 06:05:49
问题 I'm working on Laravel 5.1 and I have the following code: //Routes.php Route::get('/listagem/{campo}','ControllerParque@listar'); //ControllerParque.php public function listar($campo) { $listagem = DB::SELECT("SELECT COUNT(x.".$campo.") AS nreg, x.* FROM (SELECT * FROM computadores ORDER BY id DESC) AS x GROUP BY ".$campo." ORDER BY ".$campo." ASC"); $dados = array('listagem' => $listagem, 'campo' => $campo); return view("ViewListagem")->with($dados); } I would like to restrict anything

«if statement» for nested routes

谁都会走 提交于 2019-12-12 05:40:06
问题 I have nested routes in my routes.rb resources :companies do resources :employees resources :accounts end In top menu I want to show a certain link when user is in company's controller or in nested controllers (employees, accounts). So, I want a simple «if statement» for it. I've tried several approaches. <%= if params[:company_id].present? %> # doesn't work in company views # certain link <% end %> <%= if current_page?(controller: 'companies') %> # doesn't work in nested controllers' views #

unable to get route name from url in zend framework 2

流过昼夜 提交于 2019-12-12 05:35:55
问题 I'm using Zend Framework 2, this is my code: $prevsingletrackurl = $this->getRequest()->getHeader('Referer')->getUri(); From this code which is defined in a controller's method I'm getting previous URL, now what I need to know some information of this from this, it contains which route, controller, method for my own requirement. 回答1: You can use the route stack itself to try to match it. It will return you a RouteMatch if the request object matched: use Zend\Mvc\Router\RouteMatch; $referer =

Path method displayed with rake routes is still undefined

有些话、适合烂在心里 提交于 2019-12-12 05:15:08
问题 After getting rid of this question, I get one another. I have a path method specified in routes resources :tree_nurseries do ... . And shows correctly when I do rake routes which gives new_tree_nursery then normally new_tree_nursery_path will be available. But, when I call it with a link_to method, it remains undefiend.... ( new_tree_nursery_path ) What did I missed again? this is the code line : .actions = link_to t('.new', :default => t("helpers.links.new")), new_tree_nursery_path, :class =

Rails 4 match all routes for one controller

我们两清 提交于 2019-12-12 05:12:30
问题 I have a controller with a number of static pages and I would ideally like to route them all with a wildcard. Is it possible to do something like the following? get 'static/:action' 回答1: Why don't you just use the show action: #config/routes.rb resources :static, param: :page, only: :show #-> url.com/static/:page #app/controllers/static_controller.rb class StaticController < ApplicationController def show render "#{params[:page]}" end end This way, you can pass the "page" directly through the

Rails delete link nested routes

假如想象 提交于 2019-12-12 05:03:37
问题 I'm writing a simple todo app which has projects and projects has many tasks. I want to be able to delete a task within a project. But when I try to link_to a delete method I get undefined method 'task_path'. view code <ul> <% @project.tasks.each do |task| %> <li><%= task.name %></li> <%= link_to "delete", task, :method => :delete %></br> <% end %> </ul> tasks controller def destroy @project = Project.find(params[:project_id]) @task = @project.tasks.find(params[:id]) @task.destroy redirect_to

Rails: use button_to for create action of controller

白昼怎懂夜的黑 提交于 2019-12-12 04:59:37
问题 Why can I not get my button_to to specify the create action of my controller rather than show I have tried numerous times to add :action => "create" and other such things to the button_to parameters <%= button_to "subscribe", subscription_path(feed_url: @feed.feed_url)%> do I need to specify a create route in my routes.rb? if so how should I go about that? When used the way that line is, I get this error on load: Routing Error No route matches {:action=>"show", :controller=>"subscriptions",

What is wrong in “mapping” URLs to Rails actions with this form?

房东的猫 提交于 2019-12-12 04:58:48
问题 In 'app/views/users/ reset.html.erb ' file I have this code: <%= form_tag( send_reset_users_path, :method => :post ) do %> <%= text_field_tag :email %> <%= submit_tag("Send") %> <% end %> In 'app/controllers/*users_controller.rb*' I have this code: def reset respond_to do |format| format.html # reset.html.erb end end def send_reset ... end In 'config/ routes.rb ' I have this code: resources :users do collection do get 'reset' get 'send_reset' end end When I submit the form I get the error:

Laravel 5.4 passing form select option value to a Route::get

谁都会走 提交于 2019-12-12 04:57:41
问题 I am trying to do the following within my Laravel 5.4 project. In a users.index blade page I am listing all users from a database in a table. All the users belong to a district. Some districts have more users then the other. At the top of this table view I created a form with a select field. The options hold the id's for the 10 districts: <form class="form-horizontal" method="GET" action="/users/district"> <div class="form-group col-md-5"> <select name="district" class="form-control"> <option