Giter Site home page Giter Site logo

Problem with locales about active_reload HOT 3 CLOSED

paneq avatar paneq commented on September 21, 2024
Problem with locales

from active_reload.

Comments (3)

paneq avatar paneq commented on September 21, 2024

Show me relevant parts of your Post model and controller. Does it work as expected in production mode? I suspect that your scope for retrieving posts is not defined properly. I guess you have something like this in your post.rb :

class Post
 scope :current_locale, where(:locale => I18n.locale)
end

This won't work because the condition is not evaluated every time. Instead it is evaluated only once when your class is loaded and without active_reload it happens during every request and that's why it works in development mode but won't work in production mode. You need this:

class Post
  def self.current_locale
    where(:locale => I18n.locale)
  end
end

This is similar to : http://edgeguides.rubyonrails.org/active_record_querying.html#working-with-times . You need to either use lambda syntax or define the scope as a class method. Otherwise it won't work in production mode.

That will be my guess without seeing your code. Tell me if I am right.

from active_reload.

tanraya avatar tanraya commented on September 21, 2024

Yes, you are right! I have scope :current_locale, where(:locale => I18n.locale) in my Post model. My bad. Sorry. Thanks for the clarification.

from active_reload.

paneq avatar paneq commented on September 21, 2024

Thanks for using active_reload. I hope that now it will work well for you.

from active_reload.

Related Issues (13)

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.