paper_trail | Track changes to your rails models | Database library
kandi X-RAY | paper_trail Summary
kandi X-RAY | paper_trail Summary
Track changes to your rails models
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of paper_trail
paper_trail Key Features
paper_trail Examples and Code Snippets
Community Discussions
Trending Discussions on paper_trail
QUESTION
I am trying to implement that when inside a worker a model that has paper trail is updated the whodunnit must be set with 'worker', I tried many things without success, the last one was to try a solution found in a github thread the problem is that I have workers with perfom without / with 1 or multiple params( I changed this to set PaperTrail.request.whodunnit = 'worker')
How can I set whodunnit before or around each perform, so that the whodunnit in the versions is saved as whodunnit: worker?
my workers look like this:
...ANSWER
Answered 2021-Aug-03 at 15:36The solution for me
base_worker.rb
QUESTION
I am more of a Java programmer and still somewhat new to development (2 years or so, can write Java code & web apps just fine) however the company I work for has 4 Rails applications and was asked to get this application working called CtrlPanel. I have been having to learn Ruby on Rails in order to help get this issue with this app fixed and get it working.
I have been working on this problem for over a week all day long every day and nothing I do is fixing it.
I fixed everything to the point the app comes up, web server runs serves the pages but all views are white screens as long as this application.html.haml file is present. I re-wrote the file with very basic bootstrap and it sort of works but nothing looks right. The problem seems to stem from 1 single like that simply says: = javascript_include_tag "application"
I have been all over the internet and have tried every single fix from changing coffee-script-source to v1.8.0 as I read Windows has an issue with newer rails and that file, I have tried every variation of changing it from application to default, and every type of ending you can think of no matter what I do it gives me this error message which I can not seem to find.
I am not even sure WHAT that line does, I assume it has to do with the new Google Maps API and I verified the key is valid and it was working before.
This is the error is it giving it says the line with "= javascript_include_tag" "application" giving error ExecJS::RuntimeError at / SyntaxError: [stdin]:1:1: unexpected //=
I am running a PC on Windows 10 20H2 x64 UEFI ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x64-mingw32] Rails 6.1.3
(I did also install Ubuntu on another machine and it gives the exact same error, also gives the same error on another Windows machine)
The app is working IF I delete the "application.html.haml" file and put in a skeleton basic version all of the other views start working but of course none of them look right no menus no bootstrap no nothing.
Here is the application.html.haml file.
ANSWER
Answered 2021-May-04 at 18:59I did finally figure out what this was.
The older versions of rails in this case v4.2.1 used the javascript_include_tag for the line that deals with application:
= javascript_include_tag "application"
In the newer versions of rails in my case v6.1.3.1 you have to use javascript_pack_tag
= javascript_pack_tag
This solved the issue and the views all started working. I did mention above I was working on a PC running Rails v6.1.3; however I noticed I didn't make it clear that I was also having to upgrade this program from Ruby v2.2.2 and Rails v4.2.1 to Ruby v 2.7.2 and Rails v6.1.3, that might have helped to have made that more clear. Apologies if that confused anyone. I am still VERY new to Rails and using StackOverflow.com. I am happy to report I have only 1 single issue left on this program and the rest of the program is all working properly. I will be posting another question in fact because the last issue deals with a complicated scope query and it uses different syntax again due to the newer version of rails and I haven't been able to figure it out. In any even if you are running an older version of Rails and you are trying to get the program to work on a newer version (my case as I couldn't get rails v4.2 to run or work on ANYTHING, PC, Linux nothing) then you have to change the include_tag to a pack_tag. I do not pretend to say I fully understand why. I know it has to do with webpacker but beyond that I am still learning Rails. Perhaps someone with more knowledge than myself can shed some insite as to why the syntax changed. Oh and in addition the line ended up needing to read as follows:
= javascript_pack_tag "application", "data-turbolinks-track": "reload"
I didn't have the turbolinks reference either.
I hope this helps someone else in a similar situation that I was in, it was not easy to find. I only discovered it when I went through some tutorials on making other generic apps and saw the difference on that line.
QUESTION
I have the following gems in my gem file
...ANSWER
Answered 2021-Apr-02 at 06:24My suggestion is to remove paper_trail-association_tracking from your gem file and remove any initializer and other related code. For more info refer this link https://github.com/paper-trail-gem/paper_trail/pull/1281
QUESTION
Getting an error trying to load a page. Rails 6, Ruby 2.7.1. Webpacker for javascript and SCSS From the Terminal (similar to the Chrome Console error )
...ANSWER
Answered 2020-Dec-23 at 16:46Webpacker changed from using .babelrc
to babel.config.js
between major versions 3 and 4. (Here is a link to the changelog where that is mentioned.) If this error pops up after the upgrade, it likely means that the legacy .babelrc
file is still in the root of the Rails app. The solution is to delete .babelrc
.
QUESTION
ANSWER
Answered 2020-Oct-06 at 13:09I solved this by renaming "Ad" model to "Item"
QUESTION
Let's say I have an active record model class "Post" that might or might not have paper_trail.
How can I programmatically find out if it is paper_trail enabled?
I tried things like:
...ANSWER
Answered 2020-Jul-10 at 11:16There is a special method for this PaperTrail.request.enabled_for_model?(Post)
.
QUESTION
I picked up a 4 year old project written in Ruby 2.1.3
and Rails 4.1.8
.
Very few of the gems were versioned but I've managed to get the project running locally by installing mysql2 0.3.20
as suggested in multiple other threads. Doing this required me to (on MacOS) downgrade openssl and mysql with brew install mysql@57
and brew install openssl@10
.
I could then install mysql2
with by passing the correct libraries to it:
gem install mysql2 -v 0.3.20 -- --with-mysql-config=/usr/local/opt/mysql@5.7/bin/mysql_config --with-ldflags=-L/usr/local/opt/openssl@1.0/lib --with-cppflags=-I/usr/local/opt/openssl@1.0/include
Everything works locally, all good.
I'm trying to deploy this project with Dokku on a Debian instance. Here's the readout from the push to dokku master including the error thrown when starting the Rails server:
...ANSWER
Answered 2020-Jun-22 at 18:38I think I see what's going on. In your Dockerfile, change your DB_URL from: mysql:// to mysql2://
You are loading the mysql2 gem, but indicating to ActiveRecord that you want to use a connection via the mysql gem.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install paper_trail
Add PaperTrail to your Gemfile. gem 'paper_trail'
Add a versions table to your database: bundle exec rails generate paper_trail:install [--with-changes] See section 5.c. Generators for details. bundle exec rake db:migrate
Add has_paper_trail to the models you want to track. class Widget < ActiveRecord::Base has_paper_trail end
If your controllers have a current_user method, you can easily track who is responsible for changes by adding a controller callback. class ApplicationController before_action :set_paper_trail_whodunnit end
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page