Born from yesterdays PhRug (Philippine Ruby Group) hackathon, we just want to share a gem we made that automates the creation of locale files (`es.yml`, `it.yml` from a single `en.yml` file using AI.
I'm a backend software engineer with 2 years of experience.
Recently I have been working on a small rails project. This is the first time that I need to write major frontend code. Although Hotwire makes it easy to create reactive(ish) UI, I still need a few highly interactive components.
I'm looking to use shadcn-rails or phelx_ui to do the job. From what I could tell, phelx_ui looks much easier to use, but has many components missing, while shadcn-rails is a more complete solution.
Still, I wanted to get opinion from folks who have more experience working on frontend technologies in rails.
Thanks
I saw this and looked into it briefly. I'm considering a switch to Vite for a project currently on esbuild (HMR is definitely a nice to have!).
For those using it, what convinced you to use it? Also seems pretty easy to switch over based on this .
Hey guys, how are you doing? I need to know some good gems to use in my project, i need to sign a pdf using an fpx certificate
I used 'RAILS_ENV=production bundle exec rake assets:precompile .' from this answer '' , creating secretkey etc. I went back to my original commit where it worked but it's not working. If you could help me DM me for my github because it has my name in it. Please it's very basic!
I was in an interview where I was asked a system design question. In the middle of this I was asked how would design rate limit efficiently. I could not come up with a good idea. Could you please tell me how would you go for such design. I was asked to build a similar app like online code beautyfier app. Need to know the design for logged in people and public visitors both.
I have a scenario of a users table with a phone_number column and an alternate_phone_number column. Is there a rails way of ensuring uniqueness of a number in both columns? (As in if the number is already in column one it can’t be saved in column two and vice-versa). I already have a unique index for each column. Do I just look up the number in the other column before trying to save or is there a built in way of doing this?
Hi, I was wondering if adding a <script>
tag to aplication.html.erb
would show up in all the other views of the page. In context, I want to add google analitycs to all views of the page, but I don't know if just adding it to aplication.html.erb
is enough or I need to connect it to something else, is there any way to see which views “inherit” this script from aplication.html.erb
.
I'm working on a small rails project, where I need to do some video processing in background jobs (ActiveJob with SolidQueue), and then upload the rendered video to S3 using Active Storage.
The problem is, I couldn't find any up to date video processing Ruby gems like ffmpeg, opencv etc.
I'm left with using Python for video processing (moviepy), but am struggling with integrating the whole flow with ActiveJob and ActiveStorage.
Have you guys faced such issues? What do you suggest I should do?
Thanks
We're End of July 2024 - and in a few days (August 2024) it will be 20 years that RAILS has been created 🥳. I was wondering how many of you are using RAILS for new projects? Are you using RAILS for hobby and/or professional projects?
I am curious to know if RAILS is still a good framework for the next 10 years :)
I've never picked a work laptop myself, but my Mac broke recently, so I have to. I programmed on Ubuntu a bit when I was an intern but then I was added to a project that required Mac, so I've been developing on Mac OS for the past two years. What do you guys use? The project I work on is quite old and undockerized, so some people had a lot of trouble installing it on new Apple chips, but I doubt that Ubuntu installation is smooth as well.
Below is one off the GraphQL queries in use for our API.
I need to know if it's possible for a Query, not mutation, to have multiple types.
Do I just use field
instead of type
?
module Queries class FetchLobbyCount < Queries::BaseQuery graphql_name "FetchLobbyCount" argument :user_id, Integer, required: false type Integer, null: false def resolve(user_id:) @user = User.find(user_id) unless @user.present? return GraphQL::ExecutionError.new("Cannot find user with id: #{user_id}") end User.where(awaiting_match: true).where.not(id: user_id).count end end end
Struggling with such a simple thing, I just wanted to ask and see if there's a solution or in 2024 this is still not possible.
Here's the pseudocode:
class Parent has_many :children accepts_nested_attributes_for :children end class Child validates :primary, inclusion: { in: [true, false] }, uniqueness: { scope: :parent, if: :primary? } end
I want to ensure that only one child is marked primary when I update parent with nested child records. The uniqueness validation in the pseudocode does not work because it fails when changing primary's Child A to Child B, because it doesn't look at the pending nested objects' pending changes but instead the currently persisted nested objects. The other approach I saw was to use a custom validation in the Parent class, but I can't seem to use Dirty methods or access the pending changes at all.
Answers I don't need: Just rely on a database index, do the validation by accessing the params in the controller, add a column on parent for `primary_child_id`. This is less about getting to the end result and more about whether there is a tool to elegantly achieve this in the model the way it should be possible.
There's a new blogpost on how to use Stimulus to integrate JavaScript into the Rails apps. Here's the link:
I have a navbar (in layout) with a button to the devise sign in and once it’s signed in, it goes back to the homepage and the button in the navbar is supposed to be a sign out button now. But, it’s not. However, rails does recognize that the user_signed_in is true because I put a if statement in the homepage view to say “signed in” if it’s signed in and it shows without refreshing. But, I need to refresh the page for the navbar button to change.
I’m really not sure how to fix this and couldn’t find much online about my specific problem.
Hi, I have a rails web app. I am trying to log user_id for every log line through log tag. We use devise/warden for auth, so if we had cookie store, code like attached below would work. But we use redis store.
Any ideas on how to access the actual session since ActionDispatch isn't actually initialised at the point of configuring log tags?
Rails 7, Ruby 3.
Hello I am trying to create a new project. I created a new folder and then I am trying to run "rails new portafolio --api --database=postgresql"
Then I have this error.
Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.
Any Ideas? Thanks!
I am currently looking at IDEs and have so far used VScode with a bit of success. I am looking for more features though and want to know what IDE / plugins you recommend for it:
-
Autocomplete and I mean „good“ autocomplete, including my ActiveRecord fields
-
Usage search - pretty standard feature in most languages in the „big“ IDEs but i could not get it to work with rails
-
Good erb support. If I have a button I would like to be able to get the action suggested instead of remembering the whole name (+ usage search if possible). Also I would love to have autoformatting which is clunky for me rn
Thanks for any input
I am looking for ruby on rails developer remote job having 3+ years of experience. I can immediately join if process works smoothly. Please let me know for this position, it would really be helpful for me.
EDIT: resolved. The problem is that the code has some funky stuff with a transaction that was preventing the behavior I expected.
I have a sidekiq job that eager loads records, iterates over them and passes the record to another class.
For some reason the records are _not_ being eager loaded in the second class.
I swear I've done this before and it should work but it's not?
Here's some pseudo code to replicate the setup:
class MyJob include Sidekiq::Job def perform Model.includes(:relationships).each do |model| # the puts and loaded? are just for debugging puts "relationships loaded? #{model.relationships.loaded?}" # => relationships loaded? true OtherClass.new(model).call end end end class OtherClass def initialize(model) @model = model end def call # the puts and loaded? are just for debugging puts "relationships loaded? #{@model.relationships.loaded?}" # => relationships loaded? false end end
Is it just the average places like Indeed? Or the jobs site on the rails page? (that seems like mostly FT jobs ) I see the railsjobs sub looks dead. I have a long term contract winding down and it’s been awhile since I’ve needed to find new clients. Full remote a must.