rubys / awdwr Goto Github PK
View Code? Open in Web Editor NEWAgile Web Development With Rails
Home Page: http://www.pragprog.com/titles/rails3/agile-web-development-with-rails-third-edition
Agile Web Development With Rails
Home Page: http://www.pragprog.com/titles/rails3/agile-web-development-with-rails-third-edition
I'm looking for ideas.
Agile Web Development with Rails is written with a "look at how easy it is to get started" point of view. And that's how I would like to approach Action Cable. From an Action Cable perspective, it is easy: Define a channel. Broadcast a message. Receive the message. Done.
Easy peasy.
Now the simplest scenario that this could be applied to is updating the price of something while it is being displayed:
http://intertwingly.net/projects/AWDwR4/checkdepot/section-11.6.html
Note that there are two additional steps.
The first is reasonable. After you receive a message, you want to update the DOM. And that means that you need to find the right place in the DOM to update. Which requires the view to be updated. Fair enough.
Once you found the element, you want to replace the text. As the text that is already there is formatted as currency, you want to replace it with the same thing. And that formatting is done on the server.
By default, helper methods, like number_to_currency, are not available to controllers. One way to fix it is to add an include
, which is what I'm currently doing, but it feels wrong.
Another way is to create a jbuilder view, perhaps something like this:
json.id @product.id
json.price number_to_currency(@product.price)
This view can be rendered using render_to_string, but then you have a string and ActionCable.server.broadcast
wants a Hash (that's not entirely true, it can take a string, but it will JSON encode that string).
This can be compensated for using either eval
on the server or JSON.parse
on the client, but that doesn't feel any more satisfying than include ActionView::Helpers::NumberHelper
.
The repository has links that can be updated with https.
Would a PR be acceptable for this.
Thoughts?
As per the Releasing Rails
guide of rails, it needs to pass the tests maintained in this repository to be released.
Do not release with Red AWDwR tests.
rails
also makes the following statement.
You can check the status of these tests here:
https://intertwingly.net/projects/dashboard.html
Though this repository states that these are sample output. and statement above by rails
makes one wonder if its the whole output, still the dashboard appears outdated.
I'm unaware of the storage of the test reports, but i see some here, so in case this is the right place, reports of rails 6
does not seems to be available for AWDwR4 there.
Just curious about whether rails
has stopped making you happy.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.