Can Rails Routing Helpers (i.e. mymodel_path(model)) be Used in Models?

Say I have a Rails Model called Thing. Thing has a url attribute that can optionally be set to a URL somewhere on the Internet. In view code, I need logic that does the following: <% if...

How to get next object in IEnumerable / IQueryable if ID key is not consistent?

After hacking more on my current app - once again, I am running into an issue which kills some of the joy I expected from my domain model. The problem here is that the aggregate root / most...

Where do I put helper methods for ActionMailer views?

I have a method that takes an array of strings and joins them so they do something like this: >> my_arr => ["A", "B", "C"] >> and_join(my_arr) => "A, B, and C" Which I'd like my mailer to have...

Why is using static helper methods in Java bad?

I'm asking because I'm trying to use a mocking framework (Mockito) which does not allow you to mock static methods. Looking into it I've found quite a few blog posts saying that you should have as...

Size of generic structure

I need to find out a size of a generic structure (I can not do it like sizeof(T) or using Marshal.SizeOf(...) 0> gives me an error) So I wrote: public static class HelperMethods { static...

Start UIGestureRecognizer programmatically

I want to start the UIPanGestureRecognizer right after adding it to a screenshot. Because the screenshot is created through code, when an item has been highlighted, the user won't press on the...

Use a helper method on a interpolated string

I am looking to see how I would set up my :notice to incorporate a helper method, at the moment I have this and get 'undefined method to_dollars': notice: "Thank you for your payment of...

ASP.NET MVC objects lost on post method

I just came across this topic in a current project and I would like to know the best way to handle the "problem" of objects getting lost, when using the HttpPost method when submitting a form....

How to test if a method call with arguments happened in RSpec

In my Ruby app, I'm trying to test with RSpec a module method called with arguments from a controller. The module in question is the EventTracker module to track analytics:...

Onclick-function on elements in Handlebars-template

I'm building a simple webapp with just Handlebars.js and some jQuery. Now I have a list of data, and i present them through a Handlebars-template. Then I want some actions associated with these,...

Rails helper method with link_to options as optionals

I'm trying to create a helper method that can have optional arguments for link_to method. My intention is to create a helper method for different cases: # Typical case #1 (can have any number of...

Converting C# encryption to C++ encryption

I am currently learning C++ and looking into using it for a project but I need to be able to encrypt and decrypt string. I have conversion code in various languages such as C#, Java and PHP and...

Intent.createChooser for ACTION_VIEW shows default browser only

I am trying to show a app chooser dialog using Intent.createChooser, that will list all available web browsers in user's phone. I'm using the code below: Intent browserIntent = new...

Getter and setters in Kotlin using Android

I am new to Kotlin and working on getters and setters. I am making one data class where I am setting my String values. I have 2 Activities, from ActivityA I am setting a data and I want to get it...

IntegrationTest with Mocha, stub HelperMethod (Ruby)

I got a helper method: has_permission? In a Module called: module ApplicationHelper Inside app/helpers. I also have an IntegrationTest which includes it: include ApplicationHelper My...

Deleting Image from a ViewPager

I am using a ViewPager to show my Images. These Images are sent as a List from One Activity to another & then I show them in the ViewPager. But the Issue is that if I click on a Delete Button them...

App crashed when EditText addTextChangeListener is called

On entering new input in the EditText , it crashes and closes the app I am not able to figure out the reason for the crash : Below is my code which i have tried so far : Note : the Created...

Calling a function from another class in C#/.NET MVC App

I'm trying to create better separation of concerns for code reuse in my program, that way I don't have a bloated controller that does all these different things. for instance, in my application I...

Using image_url helper in model

I'm trying to use the image_url helper in my model. I also have an image_url property on the model(can't be changed). When I call image_url, the helper method it appears to be calling the method...

WPF, how to destroy and recreate usercontrol based on changes in other, & binding problem

I am new to WPF and C#, I have a main screen consist of multiple user controls and some of the need to be destroyed and recreate on the fly based on the selection of one. Here is my sample WMMW...

WPF, How to change the properties (visibility.. ) of dynamically created UI components on load

I want to change the properties of the dynamically populated UI components. Here is my sample UI. The label and three textboxes created dynamically. I want to change the visibility of the third...

Swift 4 - How to create Custom SCNGeometry as polygon

I've been trying to create a custom SCNGeometry polygon from a set of SCNVector3 positions with the following code: private func polygonGeometry (vertices: [SCNVector3]) -> SCNGeometry { ...

Unable to handle Windows 10 pop-ups using Robot class

I am trying to run the below code in Internet Explorer, Windows 10. ----------------------------Test---------------public class SampleTest { public static void main(String args[]) throws...

Better performant quad-tree for moving and colliding objects

So basically I want to make a scene where around 50K Asteroids are spawned with a position and AABB (Axis Aligned Boundry Box) and move each one of them to a random direction which is generated in...

C++ AES Encryption getting truncated to 16 characters

I've got a function that I worked on a while ago in C++ that does AES 256 encryption using CBC. I wrote the method a while ago so I unfortunately can't remember where I got the code from, but I've...

Kivy error while trying to change the screen

I didn't want to use the .kv language. So my problem occurs when trying to run a function when I press a button. I found these question which had the same problem so I adopted the code, for the...

After I start the program Kivy crashes without any error message

I am trying to program a GUI with kivy in python. I had before this question already a Problem with my code that got resolved: Kivy error while trying to change the screen Now when I start the...

Finding Extreme points - Convex hull with C#

I want to find Extreme points and the output must be like this but my code give me this output So , i want to change it to give me correct output , How can i do that ? Thank you very much! ...

Chai-spies: expect().to.have.been.called() is failing on local methods

I'm trying to test some code written in Typescript and my test cases are failing. I've simplified the code a bit to break down my issue. I'm new to ts/js so most likely I'm just missing...

The getter 'placeName' was called on null

I created a class Address with the following strings class Address{ String placeName=''; double latitude; double longitude; String placeId= ''; String placeFormattedAddress= ''; ...