Activity
Umar,
I would say no, you do not not microservices or separate frontend/backends.
You're free to use whatever frontend you want, but in a monolithic app, think of it more like the frontend dev works on the views, css and javascript while you handle more of the controllers and models. You can get everything ready for the frontend dev, setting up forms and instance variables so they can go ahead and work with the data you provided them.
That collaboration can work if you're using a frontend framework too though. You would provide urls for them to retrieve data, but there's no need for that unless you want to.
What's the error?
Hey Umar!
I've worked a lot in the past with frontend devs as the only backend developer. For the most part, we split responsibilities such that the frontend dev would tell me what information they needed, and we would figure out the params and response formats for API requests. We'd kind of split it there so the frontend dev could handle all his needs and as the backend dev I'd just be worrying about building the API endpoints for what he needed. Inevitably you start to learn how they're building out the frontend and the frontend dev is learning how the backend works over time.
That worked out quite well for us, but there are also lots of other routes you could go.
Yeah, you were manually replacing part of the functionality that's built-in to Rails there.
I don't see anything in this code for deleting authors, just adding new ones so that's part of the problem.
It definitely works with Lightsail, but we can't help you if you don't explain what you're having trouble with.
A++++++
Hey Nino,
Editing requires the id
of the record to be in the form so it knows which record to edit. You've got _destroy
, but not id
so it wouldn't know how to delete those either.. You want it as a hidden field and permitted params.
<%= form.hidden_field :id %>
Hey Marc!
Not sure if you missed it in the episode but thats exactly how ActionText works. It uses signed global IDs to load models and it does all that automatically for you so theres nothing you need to build.
To query, you would probably need to make an adjustment since the signed global id does not have a readable value stored in the db. May just want to add a join table between the models and add references during save.
Make sure you import Trix in your JS.
Posted in denial of service attack
I would highly recommend Cloudflare.com for DDoS protection. You'll want to set it up well before you expect to get attacked so it can protect your server IPs.
Posted in Rails credentials returning nil
I've not looked into this myself yet.
If you have scoped credentials, would you just need to access them directly without the environment since it knows which environment by the filename? Have you tried this:
Rails.application.credentials.secret_key_base
Which would load the secret_key_base
from the development credentials file.
Posted in Rails credentials returning nil
Hey Nino,
Maybe this is related to Rails scoping credentials to the environment again?
Hey Ignacio,
If you look through the logs above, did it fail when installing webpacker?
Posted in jbuilder serializer for returning INDEX endpoint not working like it did with me.json.jbuilder ....
Hey Joel!
I think it's because of your render method. When you render json:
it's going to call the to_json
method on what you pass in, not render the template.
Change that to the following and you should be fine. Basically we just want to do the query in the controller and give the variable a better name. Then Rails will know to render index.json.jbuilder
when the request comes in with .json
at the end.
def index
@users = User.all
end
And accordingly, change your index.json.jbuilder file to use the @users
variable to match what was set in the action.
json.array! @users do |user|
Posted in Rubu auth without gems
Hey Ivan,
I haven't covered this yet on GoRails, but I should. This is a good tutorial to follow if you want to build auth from scratch. https://medium.com/@wintermeyer/authentication-from-scratch-with-rails-5-2-92d8676f6836
Fixed, thanks Bryan! 🙏
You can definitely create a rake task for that.
What you'd need to do is decide which associated record your want your uploads with and then scan through the directory to find your files and then open then and run the attach
method like so:
@message.image.attach(io: File.open('/path/to/file'), filename: 'file.pdf' , content_type: 'application/pdf')
Roughly you'd want to do something like:
Dir["/path/to/search/*.pdf"].each do |filename|
# Look up or create record you want to attach this file to.
# You can use the filename to parse out the customer name, etc.
# We'll assume you set it as a variable called @record.
@record = Record.first
@record.image.attach(
io: File.open(filename),
filename: File.basename(filename),
content_type: 'application/pdf'
)
end
You would need to basically add a block to your NGINX config to take /blog and render the Wordpress app.
location /blog {
root /home/deploy/blog;
try_files $uri $uri/ /index.php?$args;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php7-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Change root
to point to where your Wordpress app lives and fastcgi_pass
to point to your php-fpm sock file depending the version you're using.
It's saying your Postgres server isn't running, or it can't connect to it through the IP and port. Double check your connection settings and that Postgres is running.
It doesn't look like Roda is required anymore. You just need to include those two plugins instead of the direct_upload one.
Aside from those changes, it's probably much different. You just want your presign Javascript request to hit the presign URL and then the upload JS request needs to hit the upload_endpoint URL.