Giter VIP home page Giter VIP logo

Comments (8)

farnoy avatar farnoy commented on September 13, 2024

When you use procs to resolve such values, we expect you to store controller for our use. In model tests, you probably don't want to create controllers, so it would be convenient for you to mock this functionality and trust that it works on our side.

from public_activity.

cza0012 avatar cza0012 commented on September 13, 2024

Thank you

from public_activity.

farnoy avatar farnoy commented on September 13, 2024

And if I'm not mistaken, if you use Proc.new{ |_, model| model.dependent_logic } it should work too, but you won't be able to refer to the controller, obviously. The _ works like in Go language, you use it when you acknowledge the variable, but do not need it.

from public_activity.

thimios avatar thimios commented on September 13, 2024

In functional tests, you can set the controller like this:

PublicActivity.set_controller(@controller)

from public_activity.

cza0012 avatar cza0012 commented on September 13, 2024

I remove current_user out of a model. If you put current_user in a model, you cannot create a new object in the Rails console.

from public_activity.

farnoy avatar farnoy commented on September 13, 2024

Interesting, we do want to allow that, can you check how it works when you explicitly pass owner object? It should not exec procs then, but if it does, I'll fix it.

from public_activity.

pwalker avatar pwalker commented on September 13, 2024

So whats the current best practice for solving this issue when using the rails console? Do you need to PublicActivity.set_controller? It would be neat if we didn't need to access a controller at all from the model, in either case...

from public_activity.

farnoy avatar farnoy commented on September 13, 2024

set all params that you are usually resolving with procs before creating the activity

from public_activity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.