I am trying to use Spring in my rails project but I have my own class called Spring that inherits from another class of mine called Feature.
In my code I call .superclass on a variable that is set to Spring sometimes. It fails because the variable is set to the other Spring class. How can I set it to class I defined?
i would suggest use modules.
create your class inside a module and call it MyModule::Spring to avoid conflicts
Related
So I am trying to use this gem called 'darwinning' in my rails application
First of all,I am not very sure where to include the custom class that I create.
I want to initialize the GENE_RANGES constant in the controller(or the #genes class instance variable) , and then run the algorithm to generate best member in the controller.
I tried declaring a 'initialize' method inside the custom class to set the values for GENE_RANGES, and then use it in the controller. But that isn't working.
How to go about implementing this?
I am using Spring security rest plugin to authenticate the user. In this, there is a class named RestAuthenticationFilter. Now I want to call the methods of some custom class say CustomRestAuthenticationFilter (which extends RestAuthenticationFilter) instead of RestAuthenticationFilter. How to do this?
Is there any way that we define in resources.groovy or somewhere else that to use CustomRestAuthenticationFilter instead of RestAuthenticationFilter ?
I believe the filtering is nicely described ... in the documentation!
https://grails-plugins.github.io/grails-spring-security-core/guide/filters.html
Just amend the grails.plugin.springsecurity.filterChain.filterNamesvalue in the Config.groovy file so it contains your RestAuthenticationFilter instead of RestAuthenticationFilter and you should be good to go.
I am following a View Based Class model to setup a Calabash testing framework for my app , i.e., each view has a class containing the requisite methods for that view.
But when I call calabash functions such as "wait_for()" it throws me an error:
undefined method `wait_for' for LoggedInPage:Class (NoMethodError)
I have already added these in my env.rb
require 'calabash-cucumber/wait_helpers'
require 'calabash-cucumber/operations'
World(Calabash::Cucumber::Operations)
World(Calabash::Cucumber::WaitHelpers)
The issue probably that the page object classes aren't being initialised in the same 'world' as cucumber is running in. Adding the files to env adds them and their methods to the world that cucumber is running. You have to pass that world into your page objects when they are created to give them access to those functions.
Have your page object classes inherit from calabashes page object bases - http://www.rubydoc.info/gems/calabash-cucumber/Calabash/IBase
and when you create a new instance of a page object pass in self.
class MyPage < Calabash::IBase
...
new_instance_of_page_object = MyPage.new(self)
In this specific case, inheriting from IBase will give you access to the functions you are talking about, but passing in self will mean you have access to any other things that you have added in your env file.
I want to extend symfony's default router. I have created routing folder in lib/ and created customRouter.class.php saved it under lib/routing. I have changed factories.yml as below:
all:
routing:
class: customRouter
My customRouter.class.php is:
class customRouter extends sfPatternRouting{
}
I only extend sfPatternRouting class. When I run the application it gives me an error as below:
Catchable fatal error: Argument 1 passed to sfRouting::__construct() must be an instance of sfEventDispatcher, string given in /opt/task/lib/vendor/symfony/lib/routing/sfRouting.class.php on line 32
I do not realize the problem. I only extend the class. What is the solution to extend symfony's router?
I believe you are extending the wrong class and as such are not inheriting necessary methods. The symfony 1.4 documentation suggests extending the 'sfDoctrineRoute' class to create custom routing (as linked by #Kenny)
So I'd like to set/get a session variable from inside a plugin model that I've included to my project. I tried making a method (one getter one setter) inside the application_controller.rb but this did not work. Where can I make getter/setter methods so that a plugin model has access to them?
Create a module in the lib folder in the directory.