controller

How to get JSON data in an Odoo controller?

…衆ロ難τιáo~ 提交于 2019-12-20 02:07:25
问题 I am trying to send some JSON data to an Odoo controller, but when I send the request, I always get 404 as response. This is the code of my controller: import openerp.http as http import logging _logger = logging.getLogger(__name__) class Controller(http.Controller): @http.route('/test/result', type='json', auth='public') def index(self, **args): _logger.info('The controller is called.') return '{"response": "OK"}' Now, I type the URL ( http://localhost:8069/test/result ) on the browser to

Omniauth Facebook redirects to registration screen instead of creating user

我是研究僧i 提交于 2019-12-20 02:01:14
问题 Following the gem's tutorial exactly I still seem to be running into some issues. I first click the link to sign up via Facebook and get redirected to Facebook. I click okay and get brought back to my registration page. No new user is created. If I try to click the register link again it just refreshes the page with this in the address bar http://localhost:3000/register#_=_ . What am I doing wrong? User Model devise :database_authenticatable, :registerable, :recoverable, :rememberable,

JavaFX 2.2 -fx:include - how to access parent controller from child controller

冷暖自知 提交于 2019-12-19 18:15:23
问题 I had code from stackoverflow on "access child controller from parent controller" as below. ParentController.java public class ParentController implements Initializable{ @FXML private childController childController; @Override public void initialize(URL location, ResourceBundle resources) { childController.sessionLabel.setText("Real blabla"); System.out.println("sessionLabel= " + childController.sessionLabel.getText()); } } childController.java public class childController implements

How to show error message on rails views?

余生长醉 提交于 2019-12-19 17:44:29
问题 I am newbie in rails and want to apply validation on form fields. myviewsnew.html.erb <%= form_for :simulation, url: simulations_path do |f| %> <div class="form-group"> <%= f.label :Row %> <div class="row"> <div class="col-sm-2"> <%= f.text_field :row, class: 'form-control' %> </div> </div> </div> ..... Simulation.rb class Simulation < ActiveRecord::Base belongs_to :user validates :row, :inclusion => { :in => 1..25, :message => 'The row must be between 1 and 25' } end simulation_controller.rb

Restrict specific fields in the response of rails controller

只愿长相守 提交于 2019-12-19 13:44:09
问题 I have a controller action like def index @videos = Video.all.to_a respond_to do |format| format.xml { render :xml => @videos } format.json { render :json => @videos } end end Video has attributes name and title . I want the return xml to contain only title . How do I restrict it from the response. 回答1: Doing it like this: def index @videos = Video.all respond_to do |format| format.xml { render :xml => @videos.to_xml( :only => [:title] ) } format.json { render :json => @videos.to_json( :only

Creating foreach loops using Code Igniter controller and view

∥☆過路亽.° 提交于 2019-12-19 11:54:54
问题 This is a situation I have found myself in a few times and I just want clear it up once and for all. Best just to show you what I need to do in some example code. My Controller function my_controller() { $id = $this->uri->segment(3); $this->db->from('cue_sheets'); $this->db->where('id', $id); $data['get_cue_sheets'] = $this->db->get(); $this->db->from('clips'); $this->db->where('sheet_id', ' CUE SHEET ID GOES IN HERE ??? '); $data['get_clips'] = $this->db->get(); $this->load->view('show

Trying to share a dynamic variable between 2 controllers - Angular

狂风中的少年 提交于 2019-12-19 11:39:15
问题 Variable is named searchText and it is what will be typed in the search box by the user <input type="text" class="form-control" ng-model="searchText" placeholder=" Type KvK-nummer and Press Enter" id="typehead"> Example URL: http://localhost:8091/odata/dll-poc-dv/Account('41-125061-0000') //in brackets is the searchTeaxt What I want to achieve is to hold the value of searchText and use in 2 different controllers to pass the searchText in URL to receive data. So I get the variable in the

Magento - Query for Product Options

丶灬走出姿态 提交于 2019-12-19 10:17:50
问题 I want to write a controller that finds the different options for a given product (eg. Large, Medium, Small, Red, Blue etc...). Can anyone show me the code I would write into my controller? Additional details I'm getting closer, but I still can't figure it out. Here's the code I wrote in my controller $db = Mage::getModel('catalog/product')->load($productId); print_r($db->getOptions()); // returns an empty array echo $db->getHasOptions(); // echos 1 But when I do the print_r() on the second

Pass parameter to all views

最后都变了- 提交于 2019-12-19 09:41:13
问题 I want to display the username/last connection date/time and some other info on all of my Twig views (which all extend from a common Twig layout). How can I achieve that without having to explicitly pass those parameters from each controller to each view? Do I have to create a Twig extension, or make a call to a controller/action that will retrieve username/connection/other info from the layout using render ? I'd like a simpler solution if possible. 回答1: User is accessible as a predefined

How do I get the action name from a base controller?

霸气de小男生 提交于 2019-12-19 08:05:08
问题 I'd like to implement a base controller on one of my controllers. Within that base controller, I'd like to be able to get the current executing ActionResult name. How would I go about doing this? public class HomeController : ControllerBase { public ActionResult Index() { And; public class ControllerBase : Controller { public ControllerBase() { //method which will get the executing ActionResult } } 回答1: You can't know this in the constructor of the controller as the controller is currently