Instead of booleans (or STI), you can also use a state machine (last week pro episode ;-)) to keep track of the user's status (guest, registered user, admin...), for instance as describe in this railstips blog (this example modeli{s,z}es an inactive/active/abusive user).
Each time you create a new MIME type name (application/vnd.example.v1, application/vnd.example.v2, ...), a kitten is hurt! don't do that! that's bad!
Use MIME parameters instead: application/vnd.example; version=1, application/vnd.example; version=2, ... (version=, or level=, or v= or whatever you want, this is part of your design).
The semantic of a MIME type is that every document "flagged" with that type share the same "lineage", and that two different names are not related, even if they share a same prefix.
By incorporating a version identifier into the MIME type name, you are making the names distinct and are in the same case as if your V1 API was using text/html documents whereas your V2 now uses image/png pictures instead.
Answer to your question is in the screencast (between 6:30-6:50) and QC documentation; simply write your own worker "binary" (weird to use that term for a script file...) that only loads what's needed.
Based on the source code provided with this screencast (for the <%= yield(:head) %> in the app/views/layouts/application.html.erb ), update the app/views/snippets/show.html.erb to add:
into the else branch (the one with <pre><%= @snippet.plain_code %></pre>) that displays the plain code when the highlighted version is not available.
If you wan't a progress bar, you certainly would have to use some javascript, and have the worker in charge of the background processing to update some attribute with its progress.
Instead of booleans (or STI), you can also use a state machine (last week pro episode ;-)) to keep track of the user's status (guest, registered user, admin...), for instance as describe in this railstips blog (this example modeli{s,z}es an inactive/active/abusive user).
Each time you create a new MIME type name (
application/vnd.example.v1
,application/vnd.example.v2
, ...), a kitten is hurt! don't do that! that's bad!Use MIME parameters instead:
application/vnd.example; version=1
,application/vnd.example; version=2
, ... (version=
, orlevel=
, orv=
or whatever you want, this is part of your design).The semantic of a MIME type is that every document "flagged" with that type share the same "lineage", and that two different names are not related, even if they share a same prefix.
By incorporating a version identifier into the MIME type name, you are making the names distinct and are in the same case as if your V1 API was using
text/html
documents whereas your V2 now usesimage/png
pictures instead.Answer to your question is in the screencast (between 6:30-6:50) and QC documentation; simply write your own worker "binary" (weird to use that term for a script file...) that only loads what's needed.
Joshua Cheek's screeencast is also worth seeing, and includes a neater way to use Pry as IRB replacement for the rails console:
Simply add the following lines at the end of your config/environments/development.rb file, after the
YourAppName::Application.configure
block:And no more need to use the longer
pry -r config/environment
to start the console: simply use the usualrails console
/rails c
command.Based on the source code provided with this screencast (for the
<%= yield(:head) %>
in the app/views/layouts/application.html.erb ), update the app/views/snippets/show.html.erb to add:into the else branch (the one with
<pre><%= @snippet.plain_code %></pre>
) that displays the plain code when the highlighted version is not available.If you wan't a progress bar, you certainly would have to use some javascript, and have the worker in charge of the background processing to update some attribute with its progress.