Is there a way to make ActiveAdmin show information from a resource that isn't a database?
I have a model that's instantiated from JSON received remotely. I would like to get ActiveAdmin to show this information.
If I seed the database, ActiveAdmin will show the same number of records that I have in the seed file. When I comment out the seed, it shows nothing.
Yes, but you will have to change ActiveAdmin code, and will not be trivial.
Active admin depends on rails which depends on active record.
It also extensively use active record features on the code.
The best path to go is to write a db adapter for Rails using your API. There is one question here that addresses how to create a DB adapter.
Related
Is it possible to add the active storage models to active admin? I have tried to add them in the usual active admin way, however, the rails app just crashes.
After a few comments and a quick chat, here's the final solution:
ActiveStorage delivers active_storage_blobs, giving you an extra layer of information: metadata, url, redirects, booleans etc.
These ones are handled by ActiveStorage::Blob.
rails g active_admin:resource active_storage_blobs will throw an error. The reason is because ActiveStorage follows a different setup and ActiveRecord. In this case, get the resource directly from the Active Storage.
For now, the solution is:
rails g active_admin:resource ActiveStorage::Blob
This will display the blob data as an own index inside ActiveAdmin. Everything else should follow the same pattern as normal.
Happy coding!
I have connected my app to a MS SQL database, but I wanted to know how I can start referencing the data that was already in the database (but in another table). Do I have to generate anything in my app / resources etc.?
As Dharam said, you need to genereate Active Record model. Rails using MVC architecture, if you need to learn first about MVC, go to Rails getting started.
If you already have table, with data and structure, you don't need to generate it, you can generate ActiveRecord model without migration with this command.
rails g model ModelName --migration=false
I am new to Ruby on Rails. The rails application that I have developed has several models including one for user that stores user name, passwords and other user related information.
Now the problem is that a few columns of a table corresponding to a model has modified erratically. Now I want to know if Ralis has any feature so that I can know the user who has done this or this is because of some other reasons.
You can try installing Userstamp and maybe Paper Trail to track changes to records. If you've implemented the User model yourself (as opposed to a framework like devise), you'll need to read the docs carefully to see what properties are expected of your User models to get the full benefit.
Using devise
It adds other columns(yours) in migrate, before generate views
https://github.com/collectiveidea/audited might provide the auditing you require.
I am new to rails development. I have a simple problem but Im stumped and cant find help on google.
I have a sqlite3 database outside of my Rails app. I need to somehow get that data into my app.
What are the options?
Can I
1) somehow import the sqlite3 database and its contents into my rails app? If so what adjustments need to be made, since I know that rails inserts columns into the db: "id", "created at", "updated at"
2) If I cannot import the sqlite3 into my rails app, can I read the contents from it and enter the data into my module and then my my db?
Which if these methods is possible and which is suggested?
Could someone please point me to some resources on this topic. What exactly should I be looking for on google for this topic? any keywords?
Also does anyone know of good rails forums that are active?
Thanks,
You can specify a separate connection to that database in your database.yml. Then create a model for a table in that DB. In that model use establish_connection to tell ActiveRecord to get data for that model out of the other DB.
Look at some examples for to_model. This will show you how to transition the data into your new DB.
As far as rails inserting id, created_at and updated_at, this only happens when you use a migration to create a new table. It will not attempt to change any tables from your old DB without you telling it to. In fact, those fields are also optional on new tables.
I'm new with Ruby on Rails and want to get several records into the SQLite3 database so that I can manipulate the data. I am following a lesson, and wonder what is the fastest, most effective way to get the data into the database, which has four tables (includes one join table)?
Are there any plugins which are good for this?
I use the Faker library and Rail's new seed functionality.
Have you got data already? Is it already in a database? If so the easiest way is to just configure rails to connect to the database.
Other than that you'll want to look into seeding. This railscasts explains the process.