controller

rspec controller spec matchers

喜你入骨 提交于 2019-12-25 06:58:05
问题 With which matcher and how can I test if the @post_comment and @post_comment.user is properly assigned? expect(assigns(:post_comment)).to be_a_new(PostComment) is not working here. UPDATE: With the following setup I also get the following error. What should I change to be able to test the invalid attrs? Posts::PostCommentsController when user is logged in POST create with invalid attributes doesn't save the new product in the db Failure/Error: @post_comment.save! ActiveRecord::RecordInvalid:

how can I access a variable defined in one controller from the scope of another controller?

痞子三分冷 提交于 2019-12-25 06:55:54
问题 I have the following controllers: HeaderCtrl , NewsFeedCtrl , MainCtrl MainCtrl contains both the other two controllers, which are in the same level. I'm defining an object in authenticationService and update its value in MainCtrl and I update it frequently in NewsFeedCtrl and I want to display its value in the HTML page controlled by HeaderCtrl . when I use this line in my HeaderCtrl : $scope.unreadNum=authenticationService.notificationList.length; and then I use data binding in my HTML page

Tunning gain table to match two-curves

余生颓废 提交于 2019-12-25 06:34:10
问题 I have two data set, let us name them "actual speed" and "desired speed". My main objective is to match actual speed with the desired speed. But for doing that in my case, I need to tune FF(1x10), Integral(10x8) and Proportional gain table(10x8). My approach till now was as follows:- First, start the iteration with having 0.1 as the initial value in the first cells(FF[0]) of the FF table Then find the R-square or Co-relation between two dataset( i.e. Actual Speed and Desired Speed) Increment

rails namespace routes and controller

雨燕双飞 提交于 2019-12-25 05:46:08
问题 i just can not figure out the best way to handle the routes / controller with the following namespace. i´d just like to have the following setup: .../manage/rooms/ ( <%= @ rooms.number_of_rooms%>, <%= @ rooms.title %> ) .../manage/fuu/ ( <%= @ fuu.id %>...) ..manage/foo/ ... i know this is done by routes.rb namespace :manage do resources :rooms, :fuu, :foo end and under ... controller/manage/rooms_controller.rb and fuu_controller.rb and foo... example: class Manage::RoomsController <

UserTransaction failed when call utx.begin() throws “java.lang.IllegalStateException: Operation not allowed”

天大地大妈咪最大 提交于 2019-12-25 05:04:16
问题 i want to use ejb and jpa controller, in netbeans the controller is generated automatically... I try to call the jpa controller from class (UniversidadServiceEJB) that is a session bean stateless, I debugged the project and the UserTransaction and EntityManagerFactory is created successfully but when call the method utx.begin in the jpa controller (UniversityJpaController) throws this exception: java.lang.IllegalStateException: Operation not allowed. at com.sun.enterprise.transaction

Java FX change label in previous stage

巧了我就是萌 提交于 2019-12-25 05:01:49
问题 I have pretty simple application (i just want to understand controller switching mechanism). First window shows label and button. When you click the button, another window with button will show. Now when you click this second button, Label in first window should change. I have read some posts here, also tried this one Java FX change Label text in a previous stage scene, however, with no success. If you could explain it to me on this simple example, maybe i will be able to better understand

Rails 4 Error: ArgumentError - wrong number of arguments

懵懂的女人 提交于 2019-12-25 04:48:15
问题 I am pretty new to rails and currently coding my first application. I created a search to search through my Users (either usernames or tags - using acts_as_taggable_on gem). Following error appears: ArgumentError in UsersController#index wrong number of arguments (0 for 1) User Model # Search def self.search(search) if search where(["username LIKE ?", "%#{search}%"]) elsif searchtags none else all end end # Search Tags def self.searchtags(searchtags) if searchtags tagged_with(["#{searchtags}"

Why am I getting an undefined property error when my relationships seem correct?

筅森魡賤 提交于 2019-12-25 04:43:52
问题 I'm having a slight problem that I can't figure out, but should be really simple. I have the following model structure in my cakePHP (1.3) app: ProspectiveQuote [hasMany] QuoteUnit [belongsTo] Unit but in my ProspectiveQuotesController the line: $this->ProspectiveQuote->QuoteUnit->Unit->find('list'); gives me the following error: Undefined property: AppModel::$Unit Of course, it shouldn't be looking at AppModel, it should be looking at QuoteUnit. If I do $this->ProspectiveQuote->QuoteUnit-

Call Outlet of another view controller

天大地大妈咪最大 提交于 2019-12-25 04:37:19
问题 Hy Guys, I have a MapperViewController @interface MapperViewController : UIViewController <MKMapViewDelegate> { MKMapView *mapView; } @property (nonatomic, retain) IBOutlet MKMapView *mapView; @end In the .m file I can add annotations on a MapView after creating an object (ofc I have a MyAnnotation class) MyAnnotation *and = [[MyAnnotation alloc] init]; and.name = @"name"; and.subtitle = @"subtitle"; and.coordinate = CLLocationCoordinate2DMake(10.123,10.123); [mapView addAnnotation:and]; I

ASP.NET Web API deep model binding

拥有回忆 提交于 2019-12-25 04:22:39
问题 I've noticed (even in Web API 2.1) that deep parameter types get filled (processed by the model binder) only on the first level. That is : public class Person { public string Name { get; set; } public PersonDetails Details { get; set; } } public class PersonDetails { public string Address { get; set; } public int Age { get; set; } } // ... public class PersonController : ApiController { [HttpPost] public void ProcessPerson(Person person) { // person.Name is filled in correctly // person